Skip to content

Commit

Permalink
Added tool to test performance
Browse files Browse the repository at this point in the history
Testing shows only a small gain in 1.12 with the TAN cache
  • Loading branch information
DarkGuardsman committed Jul 12, 2017
1 parent 81fd23d commit 045ddd8
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 26 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -30,3 +30,5 @@ CompiledWith.txt
AI-Improvements.txt

AIImprovements\.txt

coverage-error\.log
48 changes: 48 additions & 0 deletions coverage-error.log
@@ -0,0 +1,48 @@
[2017.07.12 15:35:26] (Coverage): Failed to load coverage data from file: C:\Users\Rober\.IdeaIC2017.1\system\coverage\AIImprovements$Minecraft_Client.coverage
java.io.EOFException
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290)
at com.intellij.rt.coverage.util.CoverageIOUtil.readINT(CoverageIOUtil.java:130)
at com.intellij.rt.coverage.util.ProjectDataLoader.load(ProjectDataLoader.java:38)
at com.intellij.coverage.IDEACoverageRunner.loadCoverageData(IDEACoverageRunner.java:44)
at com.intellij.coverage.BaseCoverageSuite.loadProjectInfo(BaseCoverageSuite.java:245)
at com.intellij.coverage.JavaCoverageSuite.getCoverageData(JavaCoverageSuite.java:146)
at com.intellij.coverage.CoverageSuitesBundle.getCoverageData(CoverageSuitesBundle.java:96)
at com.intellij.coverage.PackageAnnotator.annotate(PackageAnnotator.java:140)
at com.intellij.coverage.JavaCoverageAnnotator.lambda$createRenewRequest$1(JavaCoverageAnnotator.java:142)
at com.intellij.coverage.BaseCoverageAnnotator$1.run(BaseCoverageAnnotator.java:36)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:726)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:176)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:556)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:501)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:66)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:163)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$1.run(ProgressManagerImpl.java:137)
at com.intellij.openapi.application.impl.ApplicationImpl$2.run(ApplicationImpl.java:334)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
[2017.07.12 15:43:37] (Coverage): Failed to load coverage data from file: C:\Users\Rober\.IdeaIC2017.1\system\coverage\AIImprovements$Minecraft_Client.coverage
java.io.EOFException
at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:290)
at com.intellij.rt.coverage.util.CoverageIOUtil.readINT(CoverageIOUtil.java:130)
at com.intellij.rt.coverage.util.ProjectDataLoader.load(ProjectDataLoader.java:38)
at com.intellij.coverage.IDEACoverageRunner.loadCoverageData(IDEACoverageRunner.java:44)
at com.intellij.coverage.BaseCoverageSuite.loadProjectInfo(BaseCoverageSuite.java:245)
at com.intellij.coverage.JavaCoverageSuite.getCoverageData(JavaCoverageSuite.java:146)
at com.intellij.coverage.CoverageSuitesBundle.getCoverageData(CoverageSuitesBundle.java:96)
at com.intellij.coverage.SrcFileAnnotator.showCoverageInformation(SrcFileAnnotator.java:289)
at com.intellij.coverage.CoverageDataManagerImpl$CoverageEditorFactoryListener.lambda$editorCreated$0(CoverageDataManagerImpl.java:695)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:223)
at com.intellij.util.Alarm$Request.runSafely(Alarm.java:418)
at com.intellij.util.Alarm$Request.access$700(Alarm.java:343)
at com.intellij.util.Alarm$Request$1.run(Alarm.java:385)
at com.intellij.util.Alarm$Request.run(Alarm.java:396)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:237)
at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:212)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
@@ -1,11 +1,5 @@
package com.builtbroken.ai.improvements;

import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLModDisabledEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAILookIdle;
Expand All @@ -15,6 +9,12 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLModDisabledEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand Down

This file was deleted.

58 changes: 58 additions & 0 deletions src/tools/java/com/builtbroken/tools/MainPerformanceTest.java
@@ -0,0 +1,58 @@
package com.builtbroken.tools;

import com.builtbroken.ai.improvements.FastTrig;
import com.builtbroken.ai.improvements.FixedEntityLookHelper;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityLookHelper;
import net.minecraft.entity.monster.EntityZombie;

import java.util.Random;

/**
* @see <a href="https://github.com/BuiltBrokenModding/VoltzEngine/blob/development/license.md">License</a> for what you can and can't do with the code.
* Created by Dark(DarkGuardsman, Robert) on 7/12/2017.
*/
public class MainPerformanceTest
{
public static void main(String... args)
{
EntityLiving living = new EntityZombie(null);

EntityLookHelper mcHelper = new EntityLookHelper(living);
EntityLookHelper helper = new FixedEntityLookHelper(living);
Random random = new Random();

FastTrig.init(); //load the cache

for (int i = 0; i < 100000; i++)
{
mcHelper.isLooking = true;
helper.isLooking = true;

int x = random.nextInt(10) - random.nextInt(10);
int y = random.nextInt(2) - random.nextInt(2);
int z = random.nextInt(10) - random.nextInt(10);

mcHelper.posX = x;
mcHelper.posY = y;
mcHelper.posZ = z;

helper.posX = x;
helper.posY = y;
helper.posZ = z;

System.out.println("[" + i + "]--------------------------------------");
long start = System.nanoTime();
mcHelper.onUpdateLook();
start = System.nanoTime() - start;

System.out.println("MC: " + start);

start = System.nanoTime();
helper.onUpdateLook();
start = System.nanoTime() - start;

System.out.println("BBM: " + start);
}
}
}

0 comments on commit 045ddd8

Please sign in to comment.