Skip to content

Commit

Permalink
Updated stats
Browse files Browse the repository at this point in the history
  • Loading branch information
slangeberg committed Nov 4, 2015
1 parent 03c3a9c commit bc0de2d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
17 changes: 10 additions & 7 deletions bundle.js
Expand Up @@ -38,6 +38,13 @@ module.exports = {
executionTimes.push(time);
},

mean: function mean(sequence) {
var sum = 0;
sequence.forEach(function (val) {
sum += val;
});
return sum / sequence.length;
},
median: function median(sequence) {
//copy
sequence = sequence.slice();
Expand All @@ -53,15 +60,16 @@ module.exports = {

executionTimes.sort(this.sortAscending);

var meanValue = this.mean(executionTimes).toFixed(4);
var medianValue = this.median(executionTimes).toFixed(4);
var finalTime = performance.now();
var totalTime = (finalTime - startTime).toFixed(4);

var printMemory = function printMemory(target) {
return target.jsHeapSizeLimit + ', totalJSHeapSize: ' + target.totalJSHeapSize + ', usedJSHeapSize: ' + target.usedJSHeapSize;
return 'jsHeapSizeLimit: ' + target.jsHeapSizeLimit + ', totalJSHeapSize: ' + target.totalJSHeapSize + ', usedJSHeapSize: ' + target.usedJSHeapSize;
};

var stats = ["------------------------------", "Execution completed with parameters: ", "maxRows: " + this.maxRows, "------------------------------", 'Execution times: ' + executionTimes, 'Median time: ' + medianValue + 'ms', 'Total time: ' + totalTime + 'ms, ' + (totalTime / 1000).toFixed(2) + 's', "------------------------------", 'Initial memory: ' + printMemory(initMemory), 'Final memory: jsHeapSizeLimit: ' + printMemory(performance.memory)];
var stats = ["------------------------------", "Execution completed with parameters: ", "maxRows: " + this.maxRows, "------------------------------", 'Execution times: ' + executionTimes, 'Avg. time: ' + meanValue + 'ms', 'Median time: ' + medianValue + 'ms', 'Total time: ' + totalTime + 'ms, ' + (totalTime / 1000).toFixed(2) + 's', "------------------------------", 'Initial memory: ' + printMemory(initMemory), 'Final memory: ' + printMemory(performance.memory)];

var div = document.createElement('div');
div.innerHTML = stats.join('<br/>');
Expand Down Expand Up @@ -108,16 +116,13 @@ var ExampleApplication = React.createClass({
displayName: 'ExampleApplication',

getInitialState: function getInitialState() {
console.log("ExampleApplication.getInitialState()");
return {
rows: []
};
},

componentDidMount: function componentDidMount() {

console.log("ExampleApplication.componentDidMount() - will render with initial state: ", this.state);

var _app = this;

var updateInterval = setInterval(function () {
Expand Down Expand Up @@ -157,8 +162,6 @@ var ExampleApplication = React.createClass({
},

render: function render() {
console.log("ExampleApplication.render() - state.rows.length: ", this.state.rows.length);

return React.createElement(InfiniteTable, { rows: this.state.rows });
}
});
Expand Down
13 changes: 11 additions & 2 deletions js/common.js
Expand Up @@ -37,6 +37,13 @@ module.exports = {
executionTimes.push(time);
},

mean: function(sequence) {
var sum = 0;
sequence.forEach(function(val){
sum += val;
});
return sum / sequence.length;
},
median: function(sequence) {
//copy
sequence = sequence.slice();
Expand All @@ -52,12 +59,13 @@ module.exports = {

executionTimes.sort(this.sortAscending)

var meanValue = this.mean(executionTimes).toFixed(4);
var medianValue = this.median(executionTimes).toFixed(4);
var finalTime = performance.now();
var totalTime = (finalTime - startTime).toFixed(4);

var printMemory = function(target) {
return target.jsHeapSizeLimit + ', totalJSHeapSize: ' + target.totalJSHeapSize + ', usedJSHeapSize: ' + target.usedJSHeapSize
return 'jsHeapSizeLimit: ' + target.jsHeapSizeLimit + ', totalJSHeapSize: ' + target.totalJSHeapSize + ', usedJSHeapSize: ' + target.usedJSHeapSize;
};

var stats = [
Expand All @@ -66,11 +74,12 @@ module.exports = {
"maxRows: " + this.maxRows,
"------------------------------",
'Execution times: ' + executionTimes,
'Avg. time: ' + meanValue + 'ms',
'Median time: ' + medianValue + 'ms',
'Total time: ' + totalTime + 'ms, ' + (totalTime/1000).toFixed(2) + 's',
"------------------------------",
'Initial memory: ' + printMemory(initMemory),
'Final memory: jsHeapSizeLimit: ' + printMemory(performance.memory)
'Final memory: ' + printMemory(performance.memory)
];

var div = document.createElement('div');
Expand Down
5 changes: 0 additions & 5 deletions js/react-app.js
Expand Up @@ -20,16 +20,13 @@ console.log("startTime: ", startTime);
var ExampleApplication = React.createClass({

getInitialState: function() {
console.log("ExampleApplication.getInitialState()");
return {
rows: []
};
},

componentDidMount: function() {

console.log("ExampleApplication.componentDidMount() - will render with initial state: ", this.state);

var _app = this;

var updateInterval = setInterval(function () {
Expand Down Expand Up @@ -71,8 +68,6 @@ var ExampleApplication = React.createClass({
},

render: function () {
console.log("ExampleApplication.render() - state.rows.length: ", this.state.rows.length);

return <InfiniteTable rows={this.state.rows}/>;
}
});
Expand Down

0 comments on commit bc0de2d

Please sign in to comment.