Hi, thanks to the developers, I found fastcall very convenient to use, it's a greate lib. But I encoutered a strange issue recently. I'm using fastcall on win10 to invoke my DLL in node.js, in the DLL there are funcitons doing some time-consuming operations. I found some strange issues when I test them using different test tools.
- Mocha
The DLL function invoked all right in DLL-layer, but it takes very long time to swith to node enviroment and to go through the rest of the test case.
- Jest
The DLL function invoked all right in DLL and node layer, so the test case goes well.
ffi works well for both mocha and jest
My enviroment:
- node: 10.2.1
- jest: 23.6.0
- mocha: 5.2.0
- fastcall: 0.2.6
I wrote a sample here:
https://github.com/ximinchao/FastCallTest
DLL code
int TestAdd(int a, int b) {
Sleep(2000);
return a + b;
}
node.js code
const path = require("path");
const fastcall = require("fastcall");
const Library = fastcall.Library;
const lib = new Library(path.resolve(__dirname, "TestLib.dll"));
lib.asyncFunction("int TestAdd(int a, int b)");
const { TestAdd } = lib.interface;
const testAdd = async (a, b) => {
console.log("before dll called");
const c = await TestAdd(a, b);
console.log("after dll called");
return c;
};
module.exports = { testAdd };
mocha test code (invoke very slow, causes timeout)
const assert = require("chai").assert;
const lib = require("../src");
describe("library test", function() {
it("addTest test", async function() {
this.timeout(10000);
let res = await lib.testAdd(1, 2);
assert.equal(res, 3, "first add failed");
res = await lib.testAdd(2, 2);
assert.equal(res, 4, "first add failed");
});
});
jest test code (test ok, takes about 6-7 seconds on my computer)
const lib = require("../src");
test("testAdd test", async function() {
let res = 0;
res = await lib.testAdd(1, 2);
expect(res).toEqual(3);
res = await lib.testAdd(2, 2);
expect(res).toEqual(4);
});
Thank you for your solutions~
Hi, thanks to the developers, I found fastcall very convenient to use, it's a greate lib. But I encoutered a strange issue recently. I'm using fastcall on win10 to invoke my DLL in node.js, in the DLL there are funcitons doing some time-consuming operations. I found some strange issues when I test them using different test tools.
The DLL function invoked all right in DLL-layer, but it takes very long time to swith to node enviroment and to go through the rest of the test case.
The DLL function invoked all right in DLL and node layer, so the test case goes well.
ffi works well for both mocha and jest
My enviroment:
I wrote a sample here:
https://github.com/ximinchao/FastCallTest
DLL code
node.js code
mocha test code (invoke very slow, causes timeout)
jest test code (test ok, takes about 6-7 seconds on my computer)
Thank you for your solutions~