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
void Method(const FunctionCallbackInfo<Value>& args) { | |
v8::String::Utf8Value nameFromArgs(args[0]->ToString()); | |
std::string name = std::string(*nameFromArgs); | |
std::string response = "hello " + name; | |
args.GetReturnValue().Set(Nan::New(response).ToLocalChecked()); | |
} |
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
var addon = require('./build/Release/addon'); | |
console.log(addon.hello()); // will print 'world' |
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
{ | |
"targets": [ | |
{ | |
"target_name": "addon", | |
"sources": [ "hello.cc" ] | |
} | |
] | |
} |
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
void Method(const FunctionCallbackInfo<Value>& args) { | |
Isolate* isolate = args.GetIsolate(); | |
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "world")); | |
} |
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
void init(Local<Object> exports) { | |
NODE_SET_METHOD(exports, "hello", Method); | |
} |
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
```cpp | |
void init(Local<Object> exports) { | |
NODE_SET_METHOD(exports, "hello", Method); | |
} | |
``` |
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
void init(Local<Object> exports) { | |
NODE_SET_METHOD(exports, "hello", Method); | |
} |
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
#include <node.h> | |
namespace demo { | |
using v8::FunctionCallbackInfo; | |
using v8::Isolate; | |
using v8::Local; | |
using v8::Object; | |
using v8::String; | |
using v8::Value; |
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
func merge_sort_async(l []int, c chan []int) { | |
if len(l) < 2 { | |
c <- l | |
return | |
} | |
if len(l) < 500 { //TUNE THIS NUMER AND DONT CREATE EXTRA WORK UNLESS IT'S BIGGER | |
c <- merge_sort(l) | |
return | |
} | |
mid := len(l) / 2 |
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
$ go test -bench=. -benchtime 10s mergesort_test.go | |
testing: warning: no tests to run | |
PASS | |
BenchmarkMSAsync 1 88944871528 ns/op | |
ok command-line-arguments 92.272s |