670 stat.ts = tsTo - tsFrom; |
670 stat.ts = tsTo - tsFrom; |
671 stats.push(stat); |
671 stats.push(stat); |
672 if (tsTo - tsLimitFrom >= tsLimit) |
672 if (tsTo - tsLimitFrom >= tsLimit) |
673 break; |
673 break; |
674 } |
674 } |
675 console.log(stats); |
675 var histo = {}; |
|
676 for (i = stats.length-1; i >= 0; i--) { |
|
677 var stat = stats[i]; |
|
678 if ( ! histo[stat.max]) |
|
679 histo[stat.max] = { n: 0, minSpeed: Infinity, meanSpeed: 0, maxSpeed: 0, minTurn: Infinity, meanTurn: 0, maxTurn: 0, minScore: Infinity, meanScore: 0, maxScore: 0 }; |
|
680 var row = histo[stat.max]; |
|
681 row.n++; |
|
682 var speed = (stat.turn * 1000.0) / stat.ts; |
|
683 row.minSpeed = Math.min(row.minSpeed, speed); |
|
684 row.meanSpeed += speed; |
|
685 row.minSpeed = Math.max(row.minSpeed, speed); |
|
686 row.minTurn = Math.min(row.minTurn, stat.turn); |
|
687 row.meanTurn += stat.turn; |
|
688 row.maxTurn = Math.max(row.minTurn, stat.turn); |
|
689 row.minScore = Math.min(row.minScore, stat.score); |
|
690 row.meanScore += stat.score; |
|
691 row.maxScore = Math.max(row.minScore, stat.score); |
|
692 } |
|
693 for (var i in histo) { |
|
694 var row = histo[i]; |
|
695 var n = row.n; |
|
696 row.meanSpeed = row.meanSpeed / n; |
|
697 row.meanTurn = row.meanTurn / n; |
|
698 row.meanScore = row.meanScore / n; |
|
699 } |
|
700 console.log(histo); |
676 } |
701 } |
677 |
702 |
678 var statisticBtn = document.getElementById('statistic'); |
703 var statisticBtn = document.getElementById('statistic'); |
679 statisticBtn.addEventListener("click", statistic, false); |
704 statisticBtn.addEventListener("click", statistic, false); |
680 |
705 |