Code Monkey home page Code Monkey logo

Comments (8)

vext01 avatar vext01 commented on September 20, 2024

Another alternative is to try and call clock_gettime_monotonic() in libkruntime, but I don't know how hard calling C is in (J)ruby.

from krun.

cfbolz avatar cfbolz commented on September 20, 2024

We may have to go for that, because it seems that jruby does not define Process::CLOCK_MONOTONIC_RAW

from krun.

cfbolz avatar cfbolz commented on September 20, 2024

Ok, chatted with Chris. There is no FFI in truffleruby yet. Thus we have to change truffleruby. I'll need some help with this, my java is not good enough. I think this is the beginning of the patch we need:

diff --git a/truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java b/truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
index 356a478..04c4796 100644
--- a/truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
+++ b/truffle/src/main/java/org/jruby/truffle/nodes/core/TrufflePrimitiveNodes.java
@@ -127,6 +127,21 @@ public abstract class TrufflePrimitiveNodes {

     }

+    @CoreMethod(names = "clock_gettime_monotonic", onSingleton = true)
+    public abstract static class MonotonicTimeNode extends CoreMethodArrayArgumentsNode {
+
+        public MonotonicTimeNode(RubyContext context, SourceSection sourceSection) {
+            super(context, sourceSection);
+        }
+
+        @TruffleBoundary
+        @Specialization
+        public double clockGettimeMonotonic() {
+            return IterationsRunner.JNI_clock_gettime_monotonic();
+        }
+
+    }
+
     @CoreMethod(names = "gc_time", onSingleton = true)
     public abstract static class GCTimeNode extends CoreMethodArrayArgumentsNode {

but the class IterationsRunner is of course not found. How do I fix that part?

from krun.

cfbolz avatar cfbolz commented on September 20, 2024

Ok, IterationsRunner is in an "unnamed package", which can't be used from any other Java code in a package. Do we make it a package?

from krun.

vext01 avatar vext01 commented on September 20, 2024

Looks like we need to:
http://stackoverflow.com/questions/283816/how-to-access-java-classes-in-the-default-package

from krun.

cfbolz avatar cfbolz commented on September 20, 2024

reflection, do we really want to do that?

from krun.

cfbolz avatar cfbolz commented on September 20, 2024

Wouldn't that produce too much overhead for the timing call?

from krun.

vext01 avatar vext01 commented on September 20, 2024

Woops. To be clear.

Looks like we do need to put out code in a package, due to You can’t use classes in the default package from a named package. I didn't mean to use reflection.

from krun.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.