File tree Expand file tree Collapse file tree 7 files changed +46
-61
lines changed
Expand file tree Collapse file tree 7 files changed +46
-61
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ build /
Original file line number Diff line number Diff line change 1+ binding :
2+ node-gyp rebuild --nodedir=../../..
Original file line number Diff line number Diff line change 11#include < v8.h>
22#include < node.h>
3- #include < time.h>
43
54using namespace v8 ;
65
76static int c = 0 ;
87
98static Handle<Value> Hello (const Arguments& args) {
109 HandleScope scope;
11- // time_t tv = time(NULL);
1210 return scope.Close (Integer::New (c++));
1311}
1412
1513extern " C" void init (Handle<Object> target) {
1614 HandleScope scope;
17- // target->Set(String::New("hello"), String::New("World"));
1815 NODE_SET_METHOD (target, " hello" , Hello);
1916}
17+
18+ NODE_MODULE (binding, init);
Original file line number Diff line number Diff line change 1+ {
2+ 'targets' : [
3+ {
4+ 'target_name' : 'binding' ,
5+ 'sources' : [ 'binding.cc' ]
6+ }
7+ ]
8+ }
Original file line number Diff line number Diff line change 1+ // show the difference between calling a short js function
2+ // relative to a comparable C++ function.
3+ // Reports millions of calls per second.
4+ // Note that JS speed goes up, while cxx speed stays about the same.
5+
6+ var assert = require ( 'assert' ) ;
7+ var common = require ( '../../common.js' ) ;
8+
9+ var binding = require ( './build/Release/binding' ) ;
10+ var cxx = binding . hello ;
11+
12+ var c = 0 ;
13+ function js ( ) {
14+ return c ++ ;
15+ }
16+
17+ assert ( js ( ) === cxx ( ) ) ;
18+
19+ var bench = common . createBenchmark ( main , {
20+ type : [ 'js' , 'cxx' ] ,
21+ millions : [ 1 , 10 , 50 ]
22+ } ) ;
23+
24+ function main ( conf ) {
25+ var n = + conf . millions * 1e6 ;
26+
27+ var fn = conf . type === 'cxx' ? cxx : js ;
28+ bench . start ( ) ;
29+ for ( var i = 0 ; i < n ; i ++ ) {
30+ fn ( ) ;
31+ }
32+ bench . end ( + conf . millions ) ;
33+ }
You can’t perform that action at this time.
0 commit comments