4343import java .lang .invoke .MethodHandles ;
4444import java .util .stream .IntStream ;
4545
46- import org .graalvm .polyglot .Context ;
47- import org .graalvm .polyglot .Engine ;
4846import org .openjdk .jmh .annotations .Benchmark ;
4947import org .openjdk .jmh .annotations .CompilerControl ;
5048import org .openjdk .jmh .annotations .Param ;
5149import org .openjdk .jmh .annotations .Scope ;
5250import org .openjdk .jmh .annotations .Setup ;
5351import org .openjdk .jmh .annotations .State ;
54- import org .openjdk .jmh .annotations .TearDown ;
5552import org .openjdk .jmh .annotations .Threads ;
5653import org .openjdk .jmh .annotations .Warmup ;
5754
6259@ Warmup (iterations = 10 , time = 1 )
6360public class DynamicObjectBenchmark extends TruffleBenchmark {
6461
65- static final String TEST_LANGUAGE = "benchmark-test-language" ;
6662 private static final int PROPERTY_KEYS_PER_ITERATION = 1000 ;
6763 static final MethodHandles .Lookup LOOKUP = MethodHandles .lookup ();
6864
@@ -92,15 +88,9 @@ private static final class MyDynamicObjectWithFields extends DynamicObject {
9288
9389 @ State (Scope .Benchmark )
9490 public static class SharedEngineState {
95- final Engine engine = Engine .newBuilder ().allowExperimentalOptions (true ).option ("engine.Compilation" , "false" ).build ();
9691 final Shape rootShape = Shape .newBuilder ().layout (MyDynamicObject .class , LOOKUP ).build ();
9792 final Shape [] expectedShapes = new Shape [PROPERTY_KEYS_PER_ITERATION ];
9893
99- @ TearDown
100- public void tearDown () {
101- engine .close ();
102- }
103-
10494 private void assertSameShape (int i , Shape actualShape ) {
10595 Shape expectedShape = expectedShapes [i ];
10696 if (expectedShape == null ) {
@@ -113,26 +103,16 @@ private void assertSameShape(int i, Shape actualShape) {
113103
114104 @ State (Scope .Thread )
115105 public static class PerThreadContextState {
116- Context context ;
117106 DynamicObject object ;
118107
119108 @ Setup
120109 public void setup (SharedEngineState shared ) {
121- context = Context .newBuilder (TEST_LANGUAGE ).engine (shared .engine ).build ();
122- context .enter ();
123-
124110 object = new MyDynamicObject (shared .rootShape );
125111 for (int i = 0 ; i < PROPERTY_KEYS_PER_ITERATION ; i ++) {
126112 String key = PROPERTY_KEYS [i ];
127113 DynamicObject .PutNode .getUncached ().put (object , key , "testValue" );
128114 }
129115 }
130-
131- @ TearDown
132- public void tearDown () {
133- context .leave ();
134- context .close ();
135- }
136116 }
137117
138118 /**
0 commit comments