Revision: 3184
http://vexi.svn.sourceforge.net/vexi/?rev=3184&view=rev
Author: clrg
Date: 2008-11-07 16:02:57 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
Cut off abnormally slow test results when computing the average (a test will
never abnormally fast)
Modified Paths:
--------------
trunk/core/org.vexi.core/src_dev/org/vexi/core/TimedTest.java
Modified: trunk/core/org.vexi.core/src_dev/org/vexi/core/TimedTest.java
===================================================================
--- trunk/core/org.vexi.core/src_dev/org/vexi/core/TimedTest.java
2008-11-07 14:46:38 UTC (rev 3183)
+++ trunk/core/org.vexi.core/src_dev/org/vexi/core/TimedTest.java
2008-11-07 16:02:57 UTC (rev 3184)
@@ -1,5 +1,6 @@
package org.vexi.core;
+import java.util.Arrays;
import org.ibex.js.JSExn;
import org.ibex.util.Log;
@@ -20,9 +21,16 @@
void averageTimedTest() { averageTimedTest(20); }
void averageTimedTest(int numtests) {
- long time = 0;
- for (int i=0; numtests>i; i++) time += timedTest();
- System.out.println((time/numtests) + "ms average for
'"+this.getClass().getSimpleName()+"'");
+ long time[] = new long[numtests];
+ for (int i=0; numtests>i; i++) time[i] = timedTest();
+ // make results more consistent by ignoring abnormally slow runs
+ // caused by OS cpu spikes which skew small, fast tests most -
+ // the cut off is arbitrary, discarding the slowest 20% of tests
+ Arrays.sort(time);
+ long accumulate = 0;
+ int cutoff = (int)(2*numtests/10);
+ for (int i=0; numtests-cutoff>i; i++) accumulate += time[i];
+ System.out.println((accumulate/(numtests-cutoff)) + "ms average for
'"+this.getClass().getSimpleName()+"'");
}
static final int numboxes = 10000;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn