eclipsesource / eclipsesource/J2V8

JS -> Native Functional Call Performance

Open
#194 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.6k
Forks
387
PR merge metrics
No merged PRs in 30d

Description

Hi,

In my use case, I'm binding WebGL calls to their OpenGL counterpart in Java. I'm encountering some performance issues that I narrowed down to the time it takes to call a native function from JavaScript.

My test case is:

```
v8object.registerJavaMethod(this, "profile", "profile", new Class[] { int.class });
public void profile(int time) {

}
```

In JavaScript:

```
var time = 0;
for (var i = 0; i < 100; i++) {
let t = performance.now();
profile(i);
time += (performance.now() - t);
}

time /= 100;
```

My device is a Nexus 6P

performance.now is another native hook, so that's adding a bit to the time calculated I'm sure but the end result is the average time to call a native function according to this test is 0.4981, which at half a millisecond is already causing performance issues even just drawing a few objects in my GL scene.

I'd be very grateful to hear your thoughts on this and if there is anything I can do to speed things up.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.