make benchmark.js independent of ids (related with #232)

This commit is contained in:
Romain Beaumont 2015-09-12 18:56:36 +02:00
parent 18b09ea4bf
commit 498d9f2c81

View File

@ -5,9 +5,9 @@ var mc = require("../");
states = mc.states; states = mc.states;
var testDataWrite = [ var testDataWrite = [
{id: 0x00, params: {keepAliveId: 957759560}}, {name: 'keep_alive', params: {keepAliveId: 957759560}},
{id: 0x01, params: {message: '<Bob> Hello World!'}}, {name: 'chat', params: {message: '<Bob> Hello World!'}},
{id: 0x06, params: {x: 6.5, y: 65.62, stance: 67.24, z: 7.5, yaw: 0, pitch: 0, onGround: true}}, {name: 'position_look', params: {x: 6.5, y: 65.62, stance: 67.24, z: 7.5, yaw: 0, pitch: 0, onGround: true}},
// TODO: add more packets for better quality data // TODO: add more packets for better quality data
]; ];
@ -18,7 +18,8 @@ console.log('Beginning write test');
start = Date.now(); start = Date.now();
for(i = 0; i < ITERATIONS; i++) { for(i = 0; i < ITERATIONS; i++) {
for(j = 0; j < testDataWrite.length; j++) { for(j = 0; j < testDataWrite.length; j++) {
inputData.push(mc.createPacketBuffer(testDataWrite[j].id, states.PLAY, testDataWrite[j].params, false)); var id=mc.packetIds['play']['toServer'][testDataWrite[j].name];
inputData.push(mc.createPacketBuffer(id, states.PLAY, testDataWrite[j].params, false));
} }
} }
console.log('Finished write test in ' + (Date.now() - start) / 1000 + ' seconds'); console.log('Finished write test in ' + (Date.now() - start) / 1000 + ' seconds');