You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Kevin A. Burton" <bu...@newsmonster.org> on 2005/02/09 21:32:30 UTC

benchmark4j? Open Java benchmarking code similar to log4j?

A problem I'm having at work right now is that I need a simple 
benchmarking tool across multiple libraries.  The FeedParser is a good 
example because I want to link to the code there but also in our 
internal code which also has some intregration with our DB.

This way I can look at a histograph of operations per second and how all 
of the systems interact.

I wrote a simple prototype and here's the javadoc:

> /** * Benchmark that allows cheap and lightweight "benchmarking" (go 
> figure) of * arbitrary code. All you have to do is call inc() every 
> time a method * completes which will then increment the benchmark and 
> perform any operations * necessary to maintain the benchmark. * * This 
> class is lightweight (only requires a hashmap entry, and (24 bytes per 
> * benchmark) of storage with no external requirements. This class is 
> also * threadsafe so if you need to call this from multithreaded code 
> to benchmark * the you'll be ok. * * The benchmark is maintained as 
> number of inc()s per minute. This can be any * type of operation you 
> want. Technically the interval can be longer than a * minute but we 
> will end up with stale data. That's the tradeoff with this * type of 
> benchmark. Its cheap and easy to maintain but anything more than 60 * 
> seconds worth of data and you'll end up with a stale benchmark. * * 
> Internally we use an incremented value which is accumulated and reset 
> ever 60 * seconds. When we reset the benchmark we reset the current 
> value so that we * can start accumulating again. * * @author <a 
> href="mailto:burton@rojo.com">Kevin Burton</a> * @version $Id: 
> Adler32.java,v 1.4 2004/05/21 22:21:32 burton Exp $ */ 


Now it dawned on me that if this was OSS that it could be used similar to log4j.  One could integrate this with log4j to have it log its operations every 60 seconds so that you could enable logging of benchmark information if you're trying to debug performance.

It would also allow constructs such as:

Benchmark benchmark = Benchmark.getBenchmark( Foo.class );

try {

    benchmark.enter();

    //perform some slow complicated operation

} finally {
    benchmark.exit();
}

Then I could enable the benchmarks logging at runtime.  Since the benchmarks only require 100 bytes or so (with hashmap overhead) one could add benchmarking anywhere they wanted without much of a VM overhead.

Anyway... my NYE resolution was to make sure all of my util code becomes OSS ;)..  Any interest in having this move into the sandbox or collaborating in this somewhere?

Assuming there's interest that is.  I need it for work so I'll probably work on a proof of concept ASAP ... 

Kevin

-- 

Use Rojo (RSS/Atom aggregator).  Visit http://rojo.com. Ask me for an 
invite!  Also see irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

If you're interested in RSS, Weblogs, Social Networking, etc... then you 
should work for Rojo!  If you recommend someone and we hire them you'll 
get a free iPod!
    
Kevin A. Burton, Location - San Francisco, CA
       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: benchmark4j? Open Java benchmarking code similar to log4j?

Posted by "Kevin A. Burton" <bu...@newsmonster.org>.
robert burrell donkin wrote:

>a OSS benchmarking tool would be cool but i'm unlikely to be able to
>find the cycles to help you out... 
>
>providing that you're an ASF committer and happy licensing under ASL2,
>then the sandbox can be a useful place to start out a project (whether
>it ends up in the commons proper or not). 
>  
>
Yeah... I was probably going to do that... I have a prototype 
implementation written already and we're using it at work.  The cool 
part is that with two lines of code I can have any arbitrary benchmark 
logged.

Kevin

-- 

Use Rojo (RSS/Atom aggregator).  Visit http://rojo.com. Ask me for an 
invite!  Also see irc.freenode.net #rojo if you want to chat.

Rojo is Hiring! - http://www.rojonetworks.com/JobsAtRojo.html

If you're interested in RSS, Weblogs, Social Networking, etc... then you 
should work for Rojo!  If you recommend someone and we hire them you'll 
get a free iPod!
    
Kevin A. Burton, Location - San Francisco, CA
       AIM/YIM - sfburtonator,  Web - http://peerfear.org/
GPG fingerprint: 5FB2 F3E2 760E 70A8 6174 D393 E84D 8D04 99F1 4412


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Re: benchmark4j? Open Java benchmarking code similar to log4j?

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
a OSS benchmarking tool would be cool but i'm unlikely to be able to
find the cycles to help you out... 

providing that you're an ASF committer and happy licensing under ASL2,
then the sandbox can be a useful place to start out a project (whether
it ends up in the commons proper or not). 

- robert

On Wed, 2005-02-09 at 20:32, Kevin A. Burton wrote:
> A problem I'm having at work right now is that I need a simple 
> benchmarking tool across multiple libraries.  The FeedParser is a good 
> example because I want to link to the code there but also in our 
> internal code which also has some intregration with our DB.
> 
> This way I can look at a histograph of operations per second and how all 
> of the systems interact.
> 
> I wrote a simple prototype and here's the javadoc:
> 
> > /** * Benchmark that allows cheap and lightweight "benchmarking" (go 
> > figure) of * arbitrary code. All you have to do is call inc() every 
> > time a method * completes which will then increment the benchmark and 
> > perform any operations * necessary to maintain the benchmark. * * This 
> > class is lightweight (only requires a hashmap entry, and (24 bytes per 
> > * benchmark) of storage with no external requirements. This class is 
> > also * threadsafe so if you need to call this from multithreaded code 
> > to benchmark * the you'll be ok. * * The benchmark is maintained as 
> > number of inc()s per minute. This can be any * type of operation you 
> > want. Technically the interval can be longer than a * minute but we 
> > will end up with stale data. That's the tradeoff with this * type of 
> > benchmark. Its cheap and easy to maintain but anything more than 60 * 
> > seconds worth of data and you'll end up with a stale benchmark. * * 
> > Internally we use an incremented value which is accumulated and reset 
> > ever 60 * seconds. When we reset the benchmark we reset the current 
> > value so that we * can start accumulating again. * * @author <a 
> > href="mailto:burton@rojo.com">Kevin Burton</a> * @version $Id: 
> > Adler32.java,v 1.4 2004/05/21 22:21:32 burton Exp $ */ 
> 
> 
> Now it dawned on me that if this was OSS that it could be used similar to log4j.  One could integrate this with log4j to have it log its operations every 60 seconds so that you could enable logging of benchmark information if you're trying to debug performance.
> 
> It would also allow constructs such as:
> 
> Benchmark benchmark = Benchmark.getBenchmark( Foo.class );
> 
> try {
> 
>     benchmark.enter();
> 
>     //perform some slow complicated operation
> 
> } finally {
>     benchmark.exit();
> }
> 
> Then I could enable the benchmarks logging at runtime.  Since the benchmarks only require 100 bytes or so (with hashmap overhead) one could add benchmarking anywhere they wanted without much of a VM overhead.
> 
> Anyway... my NYE resolution was to make sure all of my util code becomes OSS ;)..  Any interest in having this move into the sandbox or collaborating in this somewhere?
> 
> Assuming there's interest that is.  I need it for work so I'll probably work on a proof of concept ASAP ... 
> 
> Kevin


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org