Skip to content

Commit

Permalink
PBI: Avoid spending time on measuring time in Processing.await, becau…
Browse files Browse the repository at this point in the history
…se the measured wait time is never used anyway
  • Loading branch information
chrisvest committed Jun 26, 2017
1 parent 802936b commit f61eb5e
Showing 1 changed file with 2 additions and 7 deletions.
Expand Up @@ -23,8 +23,6 @@


import org.neo4j.unsafe.impl.batchimport.executor.ParkStrategy; import org.neo4j.unsafe.impl.batchimport.executor.ParkStrategy;


import static java.lang.System.nanoTime;

public class Processing public class Processing
{ {
private Processing() private Processing()
Expand All @@ -38,16 +36,14 @@ private Processing()
* @param goal to feed into the {@code goalPredicate}. * @param goal to feed into the {@code goalPredicate}.
* @param healthCheck to check as to not continue waiting if not passing. * @param healthCheck to check as to not continue waiting if not passing.
* @param park {@link ParkStrategy} for each tiny little wait. * @param park {@link ParkStrategy} for each tiny little wait.
* @return how long time was spent in here, in nanos.
*/ */
public static long await( LongPredicate goalPredicate, long goal, Runnable healthCheck, ParkStrategy park ) public static void await( LongPredicate goalPredicate, long goal, Runnable healthCheck, ParkStrategy park )
{ {
if ( goalPredicate.test( goal ) ) if ( goalPredicate.test( goal ) )
{ {
return 0; return;
} }


long startTime = nanoTime();
for ( int i = 0; i < 1_000_000 && !goalPredicate.test( goal ); i++ ) for ( int i = 0; i < 1_000_000 && !goalPredicate.test( goal ); i++ )
{ // Busy loop a while { // Busy loop a while
} }
Expand All @@ -58,6 +54,5 @@ public static long await( LongPredicate goalPredicate, long goal, Runnable healt
park.park( thread ); park.park( thread );
healthCheck.run(); healthCheck.run();
} }
return nanoTime() - startTime;
} }
} }

0 comments on commit f61eb5e

Please sign in to comment.