I've recently had a significant performance issue come up and the cause was
in my own code but took a bit of tracking down as it only happened on
devices (and was much more severe on iOS devices).
The only way I could track it down was to put in a lot of logging
statements throughout the code and track the timestamps to see which
methods were taking a long time and narrow it down like that. Then removing
all the log statements as there is no LogLevel (as far as I know) and I
didn't want all that logging in a production build.
Also with no logs from newer iOS devices I had to run on an older device
where I can get logs and hope that it was the same issue (it was).
I then thought about making a simple profiler based on this process that
could be turned on and off with flags in order to mark sections of code
that need this kind of work. In order to make it more useful than log
statements though it would need to be easy to put into methods without a
lot of boilerplate or strings. I thought of annotations but they need
reflection if they are used at runtime and they can't modify the code
significantly enough at compile time without significant changes to the
structure of the classes.
So then I thought about marking the start and end of methods using new
Throwable().getStackTrace() which returns an array of StackTraceElements
and I can get the current method from that but its not implemented in CN1.
Throwable.printStackTrace outputs directly to the standard error stream so
I can't manipulate that either.
Its looking impossible due to the missing methods and no reflection - but
here is what I'm trying to solve and how I'm thinking of doing it:
1. I would prefer not to have to get source and build from source, the
beauty of CN1 is the build server and this process is a pain.
2. I would like this to show slow spots on the device, the performance
monitor or NetBeans profiling tools on the simulator are no good, this
particular issue didn't show on those at all and showed significantly on
iOS devices (3000ms+ delay).
3. I would like to be able to see logs from newer iOS devices but that's a
different issue.
4. Outputs either to the logs or to a file (or email) that I can analyse
later.
Completely automated would be great but I can't think of anyway to do this
without reflection so marking methods is fine if its a simple as possible:
public void doStuff() {
Profile.start();
//Do some things in here
Profile.stop();
}
I would like Profile.start() and Profile.stop() to automatically know which
method they are being called from, otherwise I'm reliant on providing those
as strings which is not safe from refactoring or misspelling and just adds
more complexity.
Any suggestions here? Is there a way that we can get the method name?
Barking up the wrong tree?
Cheers,
Nick
--
You received this message because you are subscribed to the Google Groups
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit
https://groups.google.com/d/msgid/codenameone-discussions/eb2d6e42-a65b-45d8-9665-41068241a08d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.