mattesgroeger / mgbenchmark Goto Github PK
View Code? Open in Web Editor NEWLibrary to measure code execution times easily
License: MIT License
Library to measure code execution times easily
License: MIT License
When you get a chance, do you mind bumping the version number?
If you just have one session to measure at a time this macros would be even simpler to use:
benchmark_start("session name")
benchmark_step("step name")
benchmark_total()
benchmark_finish()
[MGBenchmark start:@"sessionName"] uses the defaultTarget for all sessions.
+ (MGBenchmarkSession *)start:(NSString *)sessionName
{
__block MGBenchmarkSession *session = [[MGBenchmarkSession alloc] initWithName:sessionName andTarget:defaultTarget];
dispatch_sync(benchmarkQueue, ^
{
sessions[sessionName] = session;
});
return session;
}
Consider adding the following, to allow specifying the target when starting a new session:
MGBenchmark.h
/**
* Starts a new session and assigns the target. An instance
* of the session is returned.
*/
+ (MGBenchmarkSession *)start:(NSString *)sessionName target:(id<MGBenchmarkTarget>)target;
MGBenchmark.m
+ (MGBenchmarkSession *)start:(NSString *)sessionName
{
return [self start:sessionName target:defaultTarget];
}
+ (MGBenchmarkSession *)start:(NSString *)sessionName target:(id<MGBenchmarkTarget>)target
{
__block MGBenchmarkSession *session = [[MGBenchmarkSession alloc] initWithName:sessionName andTarget:target];
dispatch_sync(benchmarkQueue, ^
{
sessions[sessionName] = session;
});
return session;
}
Currently, the enabling/disabling of benchmarking is done via the presence of the DEBUG macro. In my usage of this tool, I've wanted to build for Release with benchmarking enabled.
Would you be open to using a different flag?
#ifdef MGBENCHMARK
...
Occasionally (0.03%) benchmarking a step in our game causes this crash:
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x220826ed
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x392525b0 _objc_msgSend + 16
1 PocketUniverse 0x0020cae5 -[MGBenchmarkSession timePassedSince:] (MGBenchmarkSession.m:82)
2 PocketUniverse 0x0020c9b9 -[MGBenchmarkSession step:] (MGBenchmarkSession.m:60)
[...]
It's called from various different places. No repeating pattern to see.
You might not want to have the benchmark running in the live environment. The lib should provide an easy way to disable the execution.
DISPATCH_QUEUE_SERIAL or DISPATCH_QUEUE_CONCURRENT
If you measure different steps for a session, you might be interested in what actually takes the longest. Therefore a target that just collects data for each step and then prints out a sorted list of steps on demand would be helpful.
I didn't test this myself yet but I got this report from someone else. I need to check this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.