add bench test
This commit is contained in:
parent
2e7f5048dc
commit
7fa04f3423
@ -19,7 +19,7 @@ package baritone.bot.pathing.calc.openset;
|
||||
|
||||
import baritone.bot.pathing.calc.PathNode;
|
||||
import baritone.bot.pathing.goals.GoalBlock;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import baritone.bot.utils.pathing.BetterBlockPos;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.*;
|
||||
@ -73,7 +73,7 @@ public class OpenSetsTest {
|
||||
// generate the pathnodes that we'll be testing the sets on
|
||||
PathNode[] toInsert = new PathNode[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
PathNode pn = new PathNode(new BlockPos(0, 0, 0), new GoalBlock(new BlockPos(0, 0, 0)));
|
||||
PathNode pn = new PathNode(new BetterBlockPos(0, 0, 0), new GoalBlock(new BetterBlockPos(0, 0, 0)));
|
||||
pn.combinedCost = Math.random();
|
||||
toInsert[i] = pn;
|
||||
}
|
||||
|
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* This file is part of Baritone.
|
||||
*
|
||||
* Baritone is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Baritone is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Baritone. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package baritone.bot.utils.pathing;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import org.junit.Test;
|
||||
|
||||
public class BetterBlockPosTest {
|
||||
|
||||
@Test
|
||||
public void benchMulti() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
// eliminate any advantage to going first
|
||||
benchOne();
|
||||
}
|
||||
}
|
||||
|
||||
public void benchOne() {
|
||||
BlockPos pos = new BlockPos(1, 2, 3);
|
||||
BetterBlockPos pos2 = new BetterBlockPos(1, 2, 3);
|
||||
try {
|
||||
Thread.sleep(1000); // give GC some time
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long before1 = System.currentTimeMillis();
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
pos.up();
|
||||
}
|
||||
long after1 = System.currentTimeMillis();
|
||||
try {
|
||||
Thread.sleep(1000); // give GC some time
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long before2 = System.currentTimeMillis();
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
pos2.up();
|
||||
}
|
||||
long after2 = System.currentTimeMillis();
|
||||
System.out.println((after1 - before1) + " " + (after2 - before2));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user