-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from DigitalSmile/development
Interface to work with operations Tests and demo Documentation
- Loading branch information
Showing
52 changed files
with
2,288 additions
and
641 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/jmh/java/com/digitalsmile/hexgrid/operations/RangeOperationsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.digitalsmile.hexgrid.operations; | ||
|
||
import org.digitalsmile.hexgrid.hexagon.Hexagon; | ||
import org.digitalsmile.hexgrid.operations.RangeOperations; | ||
import org.openjdk.jmh.annotations.Scope; | ||
import org.openjdk.jmh.annotations.State; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
public class RangeOperationsTest { | ||
|
||
@State(Scope.Thread) | ||
public static class Input { | ||
public Hexagon hexagon = new Hexagon(0,0,0); | ||
public int range = 100; | ||
} | ||
|
||
//@Benchmark | ||
public void testGetRangeNoParallelStream(Input i, Blackhole blackhole) { | ||
var list = RangeOperations.getRange(i.hexagon, i.range); | ||
blackhole.consume(list); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/jmh/java/com/digitalsmile/hexgrid/storage/HexagonStorageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.digitalsmile.hexgrid.storage; | ||
|
||
import org.digitalsmile.hexgrid.HexagonGrid; | ||
import org.digitalsmile.hexgrid.coordinates.OffsetCoordinates; | ||
import org.digitalsmile.hexgrid.hexagon.Hexagon; | ||
import org.digitalsmile.hexgrid.layout.Orientation; | ||
import org.digitalsmile.hexgrid.shapes.rectangle.RectangleShape; | ||
import org.openjdk.jmh.annotations.*; | ||
import org.openjdk.jmh.infra.Blackhole; | ||
|
||
import java.util.Random; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
@State(Scope.Thread) | ||
public class HexagonStorageTest { | ||
private HexagonGrid<?> grid; | ||
private Hexagon hexagonToFind; | ||
|
||
@Setup | ||
public void setup() { | ||
grid = new HexagonGrid.HexagonGridBuilder<>() | ||
.hexagonWidth(150) | ||
.shape(new RectangleShape(1000, 1000), Orientation.FLAT) | ||
.hexagonDataObjectHook(Hexagon::toString) | ||
.build(); | ||
grid.generateHexagons(); | ||
var randomX = new Random().nextInt(1000); | ||
var randomY = new Random().nextInt(1000); | ||
hexagonToFind = OffsetCoordinates.toCube(Orientation.FLAT, new OffsetCoordinates(randomX, randomY)); | ||
} | ||
|
||
|
||
@Benchmark | ||
@OutputTimeUnit(TimeUnit.MICROSECONDS) | ||
public void testStorageGetMetaObjectByIndex(Blackhole blackhole) { | ||
var object = grid.getStorage().getHexagonDataObject(hexagonToFind); | ||
blackhole.consume(object); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
module hexgrids { | ||
exports org.digitalsmile.hexgrid; | ||
exports org.digitalsmile.hexgrid.hexagon; | ||
exports org.digitalsmile.hexgrid.shapes.hexagonal; | ||
exports org.digitalsmile.hexgrid.shapes.rectangle; | ||
exports org.digitalsmile.hexgrid.storage; | ||
exports org.digitalsmile.hexgrid.operations; | ||
exports org.digitalsmile.hexgrid.coordinates; | ||
exports org.digitalsmile.hexgrid.layout; | ||
exports org.digitalsmile.hexgrid.shapes; | ||
exports org.digitalsmile.hexgrid.operations.pole; | ||
} |
Oops, something went wrong.