Skip to content

Commit

Permalink
Reduce System.nanoTime() calls when profiling is enabled.
Browse files Browse the repository at this point in the history
Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed Jul 8, 2013
1 parent 005ad33 commit d1e66ed
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -29,7 +29,7 @@ public void doTick() {
Lock xMinusLock;
Lock zPlusLock;
Lock zMinusLock;
long startTime = 0;
long startTime = profilingEnabled ? System.nanoTime() : 0;
// Locking calls are manipulated by the patcher,
// INVOKEVIRTUAL java.util.concurrent.locks.Lock.lock/unlock() calls are replaced with
// MONITORENTER/MONITOREXIT instructions.
Expand All @@ -41,9 +41,6 @@ public void doTick() {
final Iterator<TileEntity> tileEntitiesIterator = tileEntitySet.startIteration();
try {
while (tileEntitiesIterator.hasNext()) {
if (profilingEnabled) {
startTime = System.nanoTime();
}
final TileEntity tileEntity = tileEntitiesIterator.next();
final int xPos = tileEntity.xCoord;
final int zPos = tileEntity.zCoord;
Expand Down Expand Up @@ -118,7 +115,8 @@ public void doTick() {
}

if (profilingEnabled) {
entityTickProfiler.record(tileEntity, System.nanoTime() - startTime);
long oldStartTime = startTime;
entityTickProfiler.record(tileEntity, (startTime = System.nanoTime()) - oldStartTime);
}
}
}
Expand Down

0 comments on commit d1e66ed

Please sign in to comment.