Git Product home page Git Product logo

Comments (6)

WeaponMan avatar WeaponMan commented on September 27, 2024

It will be good idea to get rid of HashMap and use switch or if (in single attribute case) in fromXml section if attribute has no @Path annotation. It will speed up reading and save some memory.

from tikxml.

sockeqwe avatar sockeqwe commented on September 27, 2024

For single attribute cases yes! for others I think we have to measure if switch is really faster / slower than a hashmap. It also depends on Android runtime as it does some optimization on run time.

In theory switch on Strings is O(n) whereas HashMap is O(1). However, compiler might transform switch to HashMap on compile time anyway but this depends on compiler optimizations and jdk if I remember correctly. In general i think HashMap vs. switch is a micro optimizaion and we could tackle that later. Single Attributes is an optimization (not micro optimizaion) for sure and we gain much more from optimising this compared to HashMap vs. switch.

What do you think?

from tikxml.

WeaponMan avatar WeaponMan commented on September 27, 2024

I have done some benchmarks with jmh on openjdk 1.8.0_152 linux-x64 with patches from intellij.
Turns out switch is actually cheaper than key lookup and calling method on interface, but I can upload jmh bechmark to github and you can see yourself.

from tikxml.

sockeqwe avatar sockeqwe commented on September 27, 2024

would be interesting to run those benchmarks on android device (not sure if its possible though).
Also related to #37 and #78

from tikxml.

WeaponMan avatar WeaponMan commented on September 27, 2024

Not possible with jmh, but I can create new benchmark with Caliper.

from tikxml.

WeaponMan avatar WeaponMan commented on September 27, 2024

Benchmark code can be found here
First run results on Nokia 6.1 with android 8.1 here and another one with 240 trials here

from tikxml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.