-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
417 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
'use strict' | ||
|
||
var BrowserBuffer = require('../').Buffer // (this module) | ||
var util = require('./util') | ||
var suite1 = util.suite(false) | ||
var suite2 = util.suite(false) | ||
var suite3 = util.suite(false) | ||
|
||
var LENGTH = (8192 * 3) >>> 2 | ||
var browserSubject = BrowserBuffer.alloc(LENGTH) | ||
var nodeSubject = Buffer.alloc(LENGTH) | ||
|
||
var charset = | ||
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' | ||
|
||
var str = '' | ||
|
||
for (var i = 0; i < 8192; i++) { | ||
str += charset[Math.random() * charset.length | 0] | ||
} | ||
|
||
suite1.add('BrowserBuffer.byteLength(' + str.length + ', "base64")', function () { | ||
BrowserBuffer.byteLength(str, 'base64') | ||
}) | ||
|
||
if (!process.browser) { | ||
suite1.add('NodeBuffer.byteLength(' + str.length + ', "base64")', function () { | ||
Buffer.byteLength(str, 'base64') | ||
}) | ||
} | ||
|
||
suite2.add('BrowserBuffer#write(' + str.length + ', "base64")', function () { | ||
browserSubject.write(str, 'base64') | ||
}) | ||
|
||
if (!process.browser) { | ||
suite2.add('NodeBuffer#write(' + str.length + ', "base64")', function () { | ||
nodeSubject.write(str, 'base64') | ||
}) | ||
} | ||
|
||
suite3.add('BrowserBuffer#toString(' + str.length + ', "base64")', function () { | ||
browserSubject.toString('base64') | ||
}) | ||
|
||
if (!process.browser) { | ||
suite3.add('NodeBuffer#toString(' + str.length + ', "base64")', function () { | ||
nodeSubject.toString('base64') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
var BrowserBuffer = require('../').Buffer // (this module) | ||
var util = require('./util') | ||
var suite = util.suite() | ||
|
||
var LENGTH = 8192 | ||
var browserSubject = BrowserBuffer.alloc(LENGTH) | ||
var nodeSubject = Buffer.alloc(LENGTH) | ||
|
||
var str = '' | ||
|
||
for (var i = 0; i < LENGTH; i++) { | ||
str += String.fromCharCode(Math.random() * 0x100 | 0) | ||
} | ||
|
||
suite.add('BrowserBuffer#write(' + str.length + ', "binary")', function () { | ||
browserSubject.write(str, 'binary') | ||
}) | ||
|
||
if (!process.browser) { | ||
suite.add('NodeBuffer#write(' + str.length + ', "binary")', function () { | ||
nodeSubject.write(str, 'binary') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
const BrowserBuffer = require('../').Buffer // (this module) | ||
const util = require('./util') | ||
const suite = util.suite() | ||
'use strict' | ||
|
||
const LENGTH = 4096 | ||
const browserSubject = BrowserBuffer.alloc(LENGTH) | ||
const nodeSubject = Buffer.alloc(LENGTH) | ||
var BrowserBuffer = require('../').Buffer // (this module) | ||
var util = require('./util') | ||
var suite = util.suite() | ||
|
||
const charset = '0123456789abcdef' | ||
var LENGTH = 4096 | ||
var browserSubject = BrowserBuffer.alloc(LENGTH) | ||
var nodeSubject = Buffer.alloc(LENGTH) | ||
|
||
let str = '' | ||
var charset = '0123456789abcdef' | ||
|
||
for (let i = 0; i < LENGTH * 2; i++) | ||
var str = '' | ||
|
||
for (var i = 0; i < LENGTH * 2; i++) { | ||
str += charset[Math.random() * charset.length | 0] | ||
} | ||
|
||
suite | ||
.add('BrowserBuffer#write(' + LENGTH + ', "hex")', function () { | ||
browserSubject.write(str, 'hex') | ||
}) | ||
suite.add('BrowserBuffer#write(' + str.length + ', "hex")', function () { | ||
browserSubject.write(str, 'hex') | ||
}) | ||
|
||
if (!process.browser) suite | ||
.add('NodeBuffer#write(' + LENGTH + ', "hex")', function () { | ||
if (!process.browser) { | ||
suite.add('NodeBuffer#write(' + str.length + ', "hex")', function () { | ||
nodeSubject.write(str, 'hex') | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
var BrowserBuffer = require('../').Buffer // (this module) | ||
var util = require('./util') | ||
var suite = util.suite() | ||
|
||
var LENGTH = 16384 | ||
var browserSubject = BrowserBuffer.alloc(LENGTH) | ||
var nodeSubject = Buffer.alloc(LENGTH) | ||
|
||
var str = '' | ||
|
||
for (var i = 0; i < LENGTH / 2; i++) { | ||
str += String.fromCharCode(Math.random() * 0x10000 | 0) | ||
} | ||
|
||
suite.add('BrowserBuffer#write(' + str.length + ', "ucs2")', function () { | ||
browserSubject.write(str, 'ucs2') | ||
}) | ||
|
||
if (!process.browser) { | ||
suite.add('NodeBuffer#write(' + str.length + ', "ucs2")', function () { | ||
nodeSubject.write(str, 'ucs2') | ||
}) | ||
} |
Oops, something went wrong.