/[Frey]/trunk/static/lib/Joose/Benchmark.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/static/lib/Joose/Benchmark.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 46 - (hide annotations)
Wed Jul 2 10:28:49 2008 UTC (15 years, 10 months ago) by dpavlin
File MIME type: application/javascript
File size: 969 byte(s)
added upstream Joose r4755

http://code2.0beta.co.uk/moose/svn/Joose/trunk/lib
1 dpavlin 46 // Benchmarking Class
2     Class("Joose.Benchmark", {
3     has: {
4     iterations: {},
5     func: {},
6     desc: {}
7     },
8     methods: {
9     initialize: function (iterations, desc, func) {
10     this.iterations = iterations;
11     this.func = func;
12     this.desc = desc;
13     },
14     run: function () {
15     var func = this.func;
16     var iterations = this.iterations;
17     var start = new Date().getTime();
18     for(var i = 0; i < iterations; i++) {
19     func();
20     }
21     var end = new Date().getTime();
22     return (end - start) / 1000;
23     },
24    
25     report: function () {
26     var result = this.run()
27     var perSec = Math.round(this.iterations / result);
28     return ""+this.desc + " over "+this.iterations+" iterations took "+result+" seconds ("+perSec+" iterations per second)";
29     }
30     }
31     })

  ViewVC Help
Powered by ViewVC 1.1.26