Skip to content

Commit

Permalink
test: for benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Lellansin committed Jul 25, 2017
1 parent 8a83d54 commit 0477751
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions bench/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

var Lastest = require('node-pnglib-master');
var Newest = require('..')
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;

// add tests
suite
.add('PNGlib#Lastest', function() {
let png = new Lastest(200, 150);

for (let i = 0, num = 200 / 10; i <= num; i += .01) {

let x = i * 10;
let y = Math.sin(i) * Math.sin(i) * 50 + 50;

// use a color triad of Microsofts million dollar color
png.setPixel(x, (y - 10), 'green');
png.setPixel(x, (y), '#FF00FF');
png.setPixel(x, (y + 10), 'rgb(255,0,0)');
}
})
.add('PNGlib#Newest', function() {
let png = new Newest(200, 150);

for (let i = 0, num = 200 / 10; i <= num; i += .01) {

let x = i * 10;
let y = Math.sin(i) * Math.sin(i) * 50 + 50;

// use a color triad of Microsofts million dollar color
png.setPixel(x, (y - 10), 'green');
png.setPixel(x, (y), '#FF00FF');
png.setPixel(x, (y + 10), 'rgb(255,0,0)');
}
})
// add listeners
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').map('name'));
})
// run async
.run({ 'async': true });


1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"homepage": "https://github.com/Lellansin/node-pnglib#readme",
"devDependencies": {
"benchmark": "^2.1.4",
"coveralls": "^2.13.1",
"istanbul": "^0.4.5",
"mocha": "^3.4.2",
Expand Down

0 comments on commit 0477751

Please sign in to comment.