()
| 892 | //Where each trial consists of 'iterations' of the test. |
| 893 | |
| 894 | var trialRunner = function() { |
| 895 | //Set up our function to execute a block of tests |
| 896 | var start = new Date(); |
| 897 | var tTimer = new doh.Deferred(); |
| 898 | var tCountdown = iterations; |
| 899 | |
| 900 | var tState = { |
| 901 | countdown: iterations |
| 902 | }; |
| 903 | var testRunner = function(state){ |
| 904 | while(state){ |
| 905 | try{ |
| 906 | state.countdown--; |
| 907 | if(state.countdown){ |
| 908 | var ret = fixture.runTest(doh); |
| 909 | if(ret instanceof doh.Deferred){ |
| 910 | //Deferreds have to be handled async, |
| 911 | //otherwise we just keep looping. |
| 912 | var atState = { |
| 913 | countdown: state.countdown |
| 914 | }; |
| 915 | ret.addCallback(function(){ |
| 916 | testRunner(atState); |
| 917 | }); |
| 918 | ret.addErrback(function(err) { |
| 919 | doh._handleFailure(groupName, fixture, err); |
| 920 | fixture.endTime = new Date(); |
| 921 | def.errback(err); |
| 922 | }); |
| 923 | state = null; |
| 924 | } |
| 925 | }else{ |
| 926 | tTimer.callback(new Date()); |
| 927 | state = null; |
| 928 | } |
| 929 | }catch(err){ |
| 930 | fixture.endTime = new Date(); |
| 931 | tTimer.errback(err); |
| 932 | } |
| 933 | } |
| 934 | }; |
| 935 | tTimer.addCallback(function(end){ |
| 936 | //Figure out the results and try to factor out function call costs. |
| 937 | var tResults = { |
| 938 | trial: (fixture.trialIterations - countdown), |
| 939 | testIterations: iterations, |
| 940 | executionTime: (end.getTime() - start.getTime()), |
| 941 | average: (end.getTime() - start.getTime())/iterations |
| 942 | }; |
| 943 | res.trials.push(tResults); |
| 944 | doh.debug("\n\t\tTRIAL #: " + |
| 945 | tResults.trial + "\n\tTIME: " + |
| 946 | tResults.executionTime + "ms.\n\tAVG TEST TIME: " + |
| 947 | (tResults.executionTime/tResults.testIterations) + "ms."); |
| 948 | |
| 949 | //Okay, have we run all the trials yet? |
| 950 | countdown--; |
| 951 | if(countdown){ |
no test coverage detected
searching dependent graphs…