--- /dev/null
+var binding = require('./build/default/binding');
+
+function js() {
+ return (new Date()).getTime();
+}
+
+var cxx = binding.hello;
+
+var i, N = 10000000;
+
+console.log(js());
+console.log(cxx());
+
+
+
+var start = new Date();
+for (i = 0; i < N; i++) {
+ js();
+}
+var jsDiff = new Date() - start;
+console.log(N +" JS function calls: " + jsDiff);
+
+
+var start = new Date();
+for (i = 0; i < N; i++) {
+ cxx();
+}
+var cxxDiff = new Date() - start;
+console.log(N +" C++ function calls: " + cxxDiff);
+
+console.log("\nJS speedup " + (cxxDiff / jsDiff));
+
+
--- /dev/null
+#include <v8.h>
+#include <node.h>
+#include <time.h>
+
+using namespace v8;
+
+static Handle<Value> Hello(const Arguments& args) {
+ HandleScope scope;
+ time_t tv = time(NULL);
+ return scope.Close(Integer::New(tv));
+}
+
+extern "C" void init (Handle<Object> target) {
+ HandleScope scope;
+ //target->Set(String::New("hello"), String::New("World"));
+ NODE_SET_METHOD(target, "hello", Hello);
+}
--- /dev/null
+srcdir = '.'
+blddir = 'build'
+VERSION = '0.0.1'
+
+def set_options(opt):
+ opt.tool_options('compiler_cxx')
+
+def configure(conf):
+ conf.check_tool('compiler_cxx')
+ conf.check_tool('node_addon')
+
+def build(bld):
+ obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
+ obj.target = 'binding'
+ obj.source = 'binding.cc'