mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-11 08:15:35 +03:00
Conveyor benchmark test
This commit is contained in:
parent
0d5dd146ef
commit
93cada6a16
1
.gitignore
vendored
1
.gitignore
vendored
@ -30,6 +30,7 @@ steam_appid.txt
|
||||
/android/assets/mindustry-maps/
|
||||
/android/assets/mindustry-saves/
|
||||
/core/assets/gifexport/
|
||||
#/annotations/src/main/resources/META-INF/services
|
||||
/core/assets/version.properties
|
||||
/core/assets/locales
|
||||
/ios/src/mindustry/gen/
|
||||
|
@ -1,5 +0,0 @@
|
||||
mindustry.annotations.remote.RemoteMethodAnnotationProcessor
|
||||
mindustry.annotations.impl.StructAnnotationProcessor
|
||||
mindustry.annotations.impl.SerializeAnnotationProcessor
|
||||
mindustry.annotations.impl.AssetsAnnotationProcessor
|
||||
mindustry.annotations.impl.CallSuperAnnotationProcessor
|
@ -312,7 +312,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
int direction = source == null ? 0 : Math.abs(source.relativeTo(tile.x, tile.y) - tile.rotation());
|
||||
float minitem = tile.<ConveyorEntity>ent().minitem;
|
||||
return (((direction == 0) && minitem > itemSpace) ||
|
||||
return (((direction == 0) && minitem >= itemSpace) ||
|
||||
((direction % 2 == 1) && minitem > 0.52f)) && (source == null || !(source.block().rotate && (source.rotation() + 2) % 4 == tile.rotation()));
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,23 @@
|
||||
import arc.ApplicationCore;
|
||||
import arc.Core;
|
||||
import arc.backend.headless.HeadlessApplication;
|
||||
import arc.*;
|
||||
import arc.backend.headless.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.math.geom.Point2;
|
||||
import arc.util.Log;
|
||||
import arc.util.Time;
|
||||
import mindustry.Vars;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.core.GameState.State;
|
||||
import mindustry.core.*;
|
||||
import mindustry.entities.traits.BuilderTrait.BuildRequest;
|
||||
import mindustry.entities.type.BaseUnit;
|
||||
import mindustry.core.GameState.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.entities.traits.BuilderTrait.*;
|
||||
import mindustry.entities.type.*;
|
||||
import mindustry.entities.type.base.*;
|
||||
import mindustry.game.Team;
|
||||
import mindustry.io.SaveIO;
|
||||
import mindustry.maps.Map;
|
||||
import mindustry.net.*;
|
||||
import mindustry.ctype.ContentType;
|
||||
import mindustry.type.Item;
|
||||
import mindustry.game.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.maps.*;
|
||||
import mindustry.net.Net;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.BlockPart;
|
||||
import mindustry.world.blocks.*;
|
||||
import org.junit.jupiter.api.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
@ -216,6 +214,49 @@ public class ApplicationTests{
|
||||
assertTrue(state.teams.playerCores().size > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void conveyorBench(){
|
||||
int[] items = {0};
|
||||
|
||||
world.loadMap(testMap);
|
||||
state.set(State.playing);
|
||||
int length = 10;
|
||||
world.tile(0, 0).setBlock(Blocks.itemSource);
|
||||
world.tile(0, 0).configureAny(Items.copper.id);
|
||||
|
||||
Array<TileEntity> entities = Array.with(world.tile(0, 0).entity);
|
||||
|
||||
for(int i = 0; i < length; i++){
|
||||
world.tile(i + 1, 0).setBlock(Blocks.conveyor);
|
||||
world.tile(i + 1, 0).rotation(0);
|
||||
entities.add(world.tile(i + 1, 0).entity);
|
||||
}
|
||||
|
||||
world.tile(length + 1, 0).setBlock(new Block("___"){
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
items[0] ++;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
//warmup
|
||||
for(int i = 0; i < 100000; i++){
|
||||
entities.each(TileEntity::update);
|
||||
}
|
||||
|
||||
Time.mark();
|
||||
for(int i = 0; i < 200000; i++){
|
||||
entities.each(TileEntity::update);
|
||||
}
|
||||
Log.info(Time.elapsed() + "ms to process " + items[0] + " items");
|
||||
assertTrue(items[0] > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
void load77Save(){
|
||||
resetWorld();
|
||||
|
Loading…
Reference in New Issue
Block a user