question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Performance dramatically slow

See original GitHub issue

Hi there,

I try to use the Klaxon parser together with android room.

So I have this example model:

@Entity
data class User(
        @PrimaryKey
        @Json(name = "user_id")
        var userID: String,

        @Json(name = "salutation")
        var salutation: String? = null,

        @Json(name = "company")
        var company: String? = null,

        @Json(name = "firstname")
        var firstName: String? = null,

        @Json(name = "lastname")
        var lastName: String? = null,

        @Json(name = "zip")
        var zip: String? = null
)

And want to parse it from this json string: {"firstname" : "George", "lastname" : "Clooney", "salutation" : "Herr", "user_id" : "530930", "zip" : "80335"}

And this is the code which should do all the magic:

fun getUser(): User {
        val userJson = pref!!.getString(KEY_USER, "") // the preferences stores the json string from above
        return Klaxon().parse<User>(userJson)!! // this method takes 8 seconds in debug mode!
    }

According to the Android Studio Profiler the slow method is “findJsonPaths” called in Klaxon.kt

I do have the same performance problems at any part where I’m using the klaxon parser. Any ideas for issue?

Thanks for help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
cbeustcommented, Aug 28, 2018

No, I think it’s a genuine issue. Will take a look.

1reaction
darkwood-studioscommented, Aug 28, 2018

I tried it with moshi parser and got a mush better result with this code

fun getUser(): User {
        val userJson = pref!!.getString(KEY_USER, "") // the preferences stores the json string from above
        val moshi = Moshi.Builder().build()
        val userAdapter = moshi.adapter(User::class.java)
        return userAdapter.fromJsonValue(userJson)!! // this method takes only some milli seconds!
}

Any idea why Klaxon is so much slower? Maybe I missed some configuration etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dramatically slow performance - Microsoft Community
My Windows 10 laptop has been dramatically slow for the last 8-10 days. It has 4GB DDR4 RAM, Core-i5 7200u processor, & HDD...
Read more >
My Computer is Running Slow, What Steps Can I Do to Fix It?
Make sure your computer and processor is not overheating. Excessive heat can cause a decrease in the computer's performance because most ...
Read more >
Why Your Computer Is So Slow and How To Fix It - Crucial.com
1. Identify programs that slow down your computer. 2. Check your web browser and internet connection. 3. Defragment your hard disk drive
Read more >
Why your PC is so slow... and how you can speed it up
A slow computer is often caused by too many programs running simultaneously, taking up processing power and reducing the PC's performance. Some ...
Read more >
8 Reasons Your Computer Is Slow (& How To Fix Them)
The Problem: Having too many games or programs installed on a computer can seriously slow down performance depending on how much processing power...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found