Comments (6)
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.
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.
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.
would be interesting to run those benchmarks on android device (not sure if its possible though).
Also related to #37 and #78
from tikxml.
Not possible with jmh, but I can create new benchmark with Caliper.
from tikxml.
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)
- How to initiate the lib in kotlin HOT 1
- The Future of TikXML HOT 4
- Dynamic root tag name HOT 6
- XML not generate in defined order HOT 2
- Parsing not work HOT 3
- exception while reading rss feed HOT 7
- Type converter for inserting into database HOT 2
- Problemas de parseo con dos objetos y arraylist dentro de cada uno HELP HOT 2
- Support for generic elements
- Support for iso-8859-1 HOT 7
- No TypeAdapter for class HOT 2
- java: incompatible types: java.lang.Object cannot be converted to Book HOT 2
- Docs don't mention how to make a model class for an xml like the following HOT 3
- addTypeConverter
- Support for empty lists HOT 1
- "isXXX: String" compile error
- Plans to release 0.9.x?
- Update versions of okio and guava
- Ksp support HOT 1
- how to handle br and span
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tikxml.