Hello everyone, I still studying the code to help more in the project, then I 
found a small performance improvement. That is access the field directly 
instead of using the getter setter.


```java
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 20, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(3)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
public class Benchmark {

    private final Person person = new Person();

    @Setup
    public void setup() {
    }

    @Benchmark
    public String fieldDirectly() {
        return person.name;
    }

    @Benchmark
    public String getMethod() {
        return person.getName();
    }

    private class Person {

        private final String name = "ada";

        public String getName() {
            return name;
        }
    }

}
```

* Benchmark.fieldDirectly  avgt   60  2,768 ± 0,011  ns/op 
* Benchmark.getMethod      avgt   60  3,010 ± 0,052  ns/op (around 12% slower)


[ Full content available at: https://github.com/apache/tinkerpop/pull/1001 ]
This message was relayed via gitbox.apache.org for dev@tinkerpop.apache.org

Reply via email to