Skip to content

Commit

Permalink
#3847: more jmh
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 24, 2025
1 parent 0dfed61 commit 149c54b
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
78 changes: 78 additions & 0 deletions eo-parser/src/test/java/benchmarks/XmirBench.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2025 Objectionary.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package benchmarks;

import com.jcabi.xml.XML;
import fixtures.LargeXmir;
import java.util.concurrent.TimeUnit;
import org.eolang.parser.Xmir;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;

/**
* Benchmark for XMIR to EO and to Phi transformations.
*
* @since 0.41
* @checkstyle DesignForExtensionCheck (100 lines)
*/
@Fork(1)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@Measurement(iterations = 10, time = 1, timeUnit = TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class XmirBench {

/**
* Large XMIR document.
*/
private final XML xmir = new LargeXmir().it();

@Benchmark
public void xmirToEO() {
new Xmir(this.xmir).toEO();
}

@Benchmark
public void xmirToReversedEo() {
new Xmir(this.xmir).toReversedEO();
}

@Benchmark
public void xmirToPhi() {
new Xmir(this.xmir).toPhi();
}

@Benchmark
public void xmirToSaltyPhi() {
new Xmir(this.xmir).toSaltyPhi();
}
}
4 changes: 2 additions & 2 deletions eo-parser/src/test/java/benchmarks/XslBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

/**
* Benchmark for XSL transformations.
*
* @since 0.41
* @checkstyle DesignForExtensionCheck (100 lines)
*/
@Fork(1)
@BenchmarkMode(Mode.AverageTime)
Expand Down Expand Up @@ -74,7 +74,7 @@ public class XslBench {
).back();

@Benchmark
public void apply() {
public final void manySheetsOnLargeXmir() {
new Xsline(this.sheets).pass(this.xmir);
}
}

0 comments on commit 149c54b

Please sign in to comment.