amicha24 / cpp-stopwatch Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/cpp-stopwatch
License: Other
Automatically exported from code.google.com/p/cpp-stopwatch
License: Other
How to use this code ==================== Not surprisingly, Stopwatch is a class representing a stopwatch. Stopwatch swatch(); A Stopwatch object can be used to measure execution time of code, algorithms, etc., the Stopwatch can be initialized in two time-taking modes, CPU time and real time: watch.set_mode(REAL_TIME); CPU time is the time spent by the processor on a certain piece of code, while real time is the real amount of time taken by a certain piece of code to execute (i.e. in general if you are doing hard work such as image or video editing on a different process the measured time will probably increase). How does it work? Basically, one wraps the code to be measured with the following method calls: swatch.start("My astounding algorithm"); // Hic est code swatch.stop("My astounding algorithm"); A string representing the code ID is provided so that nested portions of code can be profiled separately: swatch.start("My astounding algorithm"); swatch.start("My astounding algorithm - Super smart init"); // Initialization swatch->stop("My astounding algorithm - Super smart init"); swatch.start("My astounding algorithm - Main loop"); // Loop swatch.stop("My astounding algorithm - Main loop"); swatch.stop("My astounding algorithm"); Note: ID strings can be whatever you like, in the previous example I have used "My astounding algorithm - *" only to enforce the fact that the measured code portions are part of My astounding algorithm, but there's no connection between the three measurements. If the code for a certain task is scattered through different files or portions of the same file one can use the start-pause-stop method: swatch.start("Setup"); // First part of setup swatch.pause("Setup"); swatch.start("Main logic"); // Main logic swatch.stop("Main logic"); swatch.start("Setup"); // Cleanup (part of the setup) swatch.stop("Setup"); Finally, to report the results of the measurements just run: swatch.report("Code ID"); Thou can also provide an additional std::ostream& parameter to report() to redirect the logging on a different output. Also, you can use the get_total/min/max/average_time() methods to get the individual numeric data, without all the details of the logging. You can also extend Stopwatch to implement your own logging syntax. To report all the measurements: swatch.report_all(); Same as above, you can redirect the output by providing a std::ostream& parameter. License ======= See LICENSE file. Drop a line =========== If you use this code for your software, please let me know with a mail message at [email protected], or not.
My management thinks that "Stop" is counter intuitive name for viewing.
I had to replace it with "Count".
So, like Stopwatch::SetStopsReportName("Measurments") could be useful.
Original issue reported on code.google.com by [email protected]
on 15 Jan 2013 at 11:43
What steps will reproduce the problem?
Profile any code with the pause method on linux.
What is the expected output? What do you see instead?
Non negative numbers. Negative numbers
What version of the product are you using? On what operating system?
Ubuntu 11.4
Please provide any additional information below.
The pause method calls clock() instead of take_time() thus causing an
inconsistency with start().
Original issue reported on code.google.com by [email protected]
on 29 Aug 2012 at 12:12
report_all() - by time consumed - current behavior
report_all(SW_ORDER_TIME_CONSUMED) - current
report_all(SW_ORDER_OF_FIRST_START) - by the order of first start
Now I have to put
sw.report(msr100);
sw.report(msr50);
sw.report(msr10);
sw.report(msr1);
sw.report(msr0_1);
in the end of tests
Original issue reported on code.google.com by [email protected]
on 15 Jan 2013 at 11:39
Please move source to Mercurial or Git so I can fork it and make changes.
Or add me as developer.
Original issue reported on code.google.com by [email protected]
on 16 Jan 2013 at 8:18
It will make lib more widely usable. And I will be sure if I make some changes
still will be able to reuse it in closed project.
Original issue reported on code.google.com by [email protected]
on 16 Jan 2013 at 8:21
I use bat to run exe with you lib like
@echo Client sending request via Named pipes using custom objects reusing
initialized resources
@echo -------------
Stopwatch outputs
================================================================================
==============
Tracking performance: Client process requests ~0.1kb and gets ~1kb response of
server process
================================================================================
==============
* Avg. time 4.40001e-005 sec
* Min. time 0 sec
* Max. time 0.00100017 sec
* Tot. time 0.0880003 sec
* Stops 2000
I could be could if instead of "=" just output **Tracking performance: Client
process requests ~0.1kb and gets ~1kb response of server process**.
So my bat but gives H2 size, you lib will give Bold, list of * is OK bullet
list in terms of markdown.
I used many markups but this is so cool and usable.
So feature is
sw.report_all(SW_LANG_MARKDOWN)
Either can add SW_LANG_YAML and SW_LANG_CSV.
Thanks
Original issue reported on code.google.com by [email protected]
on 16 Jan 2013 at 8:16
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.