@@ -9,8 +9,7 @@ const bench = common.createBenchmark(main, {
99 api : [ 'legacy' , 'stream' ]
1010} ) ;
1111
12- function main ( conf ) {
13- var api = conf . api ;
12+ function main ( { api, cipher, type, len, writes } ) {
1413 if ( api === 'stream' && / ^ v 0 \. [ 0 - 8 ] \. / . test ( process . version ) ) {
1514 console . error ( 'Crypto streams not available until v0.10' ) ;
1615 // use the legacy, just so that we can compare them.
@@ -33,33 +32,33 @@ function main(conf) {
3332 // alice_secret and bob_secret should be the same
3433 assert ( alice_secret === bob_secret ) ;
3534
36- const alice_cipher = crypto . createCipher ( conf . cipher , alice_secret ) ;
37- const bob_cipher = crypto . createDecipher ( conf . cipher , bob_secret ) ;
35+ const alice_cipher = crypto . createCipher ( cipher , alice_secret ) ;
36+ const bob_cipher = crypto . createDecipher ( cipher , bob_secret ) ;
3837
3938 var message ;
4039 var encoding ;
41- switch ( conf . type ) {
40+ switch ( type ) {
4241 case 'asc' :
43- message = 'a' . repeat ( conf . len ) ;
42+ message = 'a' . repeat ( len ) ;
4443 encoding = 'ascii' ;
4544 break ;
4645 case 'utf' :
47- message = 'ü' . repeat ( conf . len / 2 ) ;
46+ message = 'ü' . repeat ( len / 2 ) ;
4847 encoding = 'utf8' ;
4948 break ;
5049 case 'buf' :
51- message = Buffer . alloc ( conf . len , 'b' ) ;
50+ message = Buffer . alloc ( len , 'b' ) ;
5251 break ;
5352 default :
54- throw new Error ( `unknown message type: ${ conf . type } ` ) ;
53+ throw new Error ( `unknown message type: ${ type } ` ) ;
5554 }
5655
5756 const fn = api === 'stream' ? streamWrite : legacyWrite ;
5857
5958 // write data as fast as possible to alice, and have bob decrypt.
6059 // use old API for comparison to v0.8
6160 bench . start ( ) ;
62- fn ( alice_cipher , bob_cipher , message , encoding , conf . writes ) ;
61+ fn ( alice_cipher , bob_cipher , message , encoding , writes ) ;
6362}
6463
6564function streamWrite ( alice , bob , message , encoding , writes ) {
0 commit comments