forked from nodejs/node-v0.x-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffer_read.js
More file actions
97 lines (80 loc) · 1.82 KB
/
Copy pathbuffer_read.js
File metadata and controls
97 lines (80 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const LEN = 1e7;
const noAssert = process.argv[3] == 'true' ? true
: process.argv[3] == 'false' ? false
: undefined;
var timer = require('./_bench_timer');
var buff = (process.argv[2] == 'slow') ?
(new require('buffer').SlowBuffer(8)) :
(new Buffer(8));
var i;
buff.writeDoubleLE(0, 0, noAssert);
timer('readUInt8', function() {
for (i = 0; i < LEN; i++) {
buff.readUInt8(0, noAssert);
}
});
timer('readUInt16LE', function() {
for (i = 0; i < LEN; i++) {
buff.readUInt16LE(0, noAssert);
}
});
timer('readUInt16BE', function() {
for (i = 0; i < LEN; i++) {
buff.readUInt16BE(0, noAssert);
}
});
timer('readUInt32LE', function() {
for (i = 0; i < LEN; i++) {
buff.readUInt32LE(0, noAssert);
}
});
timer('readUInt32BE', function() {
for (i = 0; i < LEN; i++) {
buff.readUInt32BE(0, noAssert);
}
});
timer('readInt8', function() {
for (i = 0; i < LEN; i++) {
buff.readInt8(0, noAssert);
}
});
timer('readInt16LE', function() {
for (i = 0; i < LEN; i++) {
buff.readInt16LE(0, noAssert);
}
});
timer('readInt16BE', function() {
for (i = 0; i < LEN; i++) {
buff.readInt16BE(0, noAssert);
}
});
timer('readInt32LE', function() {
for (i = 0; i < LEN; i++) {
buff.readInt32LE(0, noAssert);
}
});
timer('readInt32BE', function() {
for (i = 0; i < LEN; i++) {
buff.readInt32BE(0, noAssert);
}
});
timer('readFloatLE', function() {
for (i = 0; i < LEN; i++) {
buff.readFloatLE(0, noAssert);
}
});
timer('readFloatBE', function() {
for (i = 0; i < LEN; i++) {
buff.readFloatBE(0, noAssert);
}
});
timer('readDoubleLE', function() {
for (i = 0; i < LEN; i++) {
buff.readDoubleLE(0, noAssert);
}
});
timer('readDoubleBE', function() {
for (i = 0; i < LEN; i++) {
buff.readDoubleBE(0, noAssert);
}
});