nashorn/test/script/basic/runsunspider.js
changeset 24768 ae21f28f0ddc
parent 24751 ccbd9cd3f720
child 24778 2ff5d7041566
equal deleted inserted replaced
24767:0b8af588070b 24768:ae21f28f0ddc
   125                 runbench(path);
   125                 runbench(path);
   126                 if (typeof tests[n].actual !== 'undefined') {
   126                 if (typeof tests[n].actual !== 'undefined') {
   127                     assertEq(tests[n].actual(), tests[n].expected());
   127                     assertEq(tests[n].actual(), tests[n].expected());
   128                 }
   128                 }
   129 
   129 
       
   130                 var times = 0;
   130                 if (typeof tests[n].rerun !== 'undefined' && tests[n].times > 0) {
   131                 if (typeof tests[n].rerun !== 'undefined' && tests[n].times > 0) {
   131                     pprint("rerunning " + tests[n].name + " " + tests[n].times + " times...");
   132                     pprint("rerunning " + tests[n].name + " " + tests[n].times + " times...");
   132                     var times = 0;
       
   133                     var to = tests[n].times;
   133                     var to = tests[n].times;
   134 
   134 
   135                     var elemsPerPercent = to / 100;
   135                     var elemsPerPercent = to / 100;
   136                     var po = 0|(to / 10);
   136                     var po = 0|(to / 10);
   137 
   137 
   138                     times = 0;
   138 		    pprint("Doing warmup.");
   139                     for (; times < to; times++) {
   139                     for (times = 0; times < to; times++) {
       
   140                         initrandom();
       
   141                         tests[n].rerun();
       
   142                     }
       
   143 
       
   144 		    pprint("Doing hot runs.");
       
   145                     for (times = 0; times < to; times++) {
   140                         initrandom();
   146                         initrandom();
   141                         tests[n].rerun();
   147                         tests[n].rerun();
   142                         if ((times % (po|0)) == 0) {
   148                         if ((times % (po|0)) == 0) {
   143                             pprint(times/to * 100 + "%");
   149                             pprint("\t" + times/to * 100 + "%");
   144                         }
   150                         }
   145                     }
   151                     }
   146                 }
   152                 }
   147 
   153 
   148                 var t = new Date - dd;
   154                 var t = Math.round(((new Date - dd) / (times == 0 ? 1 : times)) * 100 / 100);
   149                 pprint("time: " + t + " ms");
   155                 pprint("time per iteration: " + t + " ms");
   150                 if (typeof tests[n].actual !== 'undefined') {
   156                 if (typeof tests[n].actual !== 'undefined') {
   151                     assertEq(tests[n].actual(), tests[n].expected());
   157                     assertEq(tests[n].actual(), tests[n].expected());
   152                 }
   158                 }
   153                 res.push(t);
   159                 res.push(t);
   154 
   160 
   155                 pprint("");
   161                 pprint("");
   156 
   162 
   157                 changed = true;
   163                 changed = true;
   158             } catch(e) {
   164             } catch(e) {
   159                 if(runall) {
   165                 if (runall) {
   160                     print("FAIL!");
   166                     print("FAIL!");
   161                 } else {
   167                 } else {
   162                     throw e;
   168                     throw e;
   163                 }
   169                 }
   164             }
   170             }
   172     }
   178     }
   173 
   179 
   174     for (var n = 0; n < tests.length; n++) {	
   180     for (var n = 0; n < tests.length; n++) {	
   175 	
   181 	
   176 	var time = "" + res[n];
   182 	var time = "" + res[n];
   177 	while (time.length < 4) {
   183 	while (time.length < 6) {
   178 	    time = " " + time;
   184 	    time = " " + time;
   179 	}
   185 	}
   180 	time += " ms";
   186 	time += " ms";
   181 	if (res[n] == -1) {
   187 	if (res[n] == -1) {
   182 	    time = "<couldn't be rerun>";
   188 	    time = "<couldn't be rerun>";