Created
December 7, 2012 01:14
-
-
Save shannah/4229924 to your computer and use it in GitHub Desktop.
Benchmark after changing to object methods.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void onMain_BtnTowerOfHanoiAction(Component c, ActionEvent event) { | |
final Label towerOfHanoiLabel = this.findLblTowerOfHanoi(); | |
towerOfHanoiLabel.setText("Calculating.... Please wait"); | |
if ( isCalculatingHanoi ){ | |
return; | |
} | |
isCalculatingHanoi = true; | |
Thread t = new Thread(new Runnable(){ | |
public void run() { | |
final TowersOfHanoi h = new TowersOfHanoi(); | |
long start = System.currentTimeMillis(); | |
h.move(30, 1, 3); | |
long end = System.currentTimeMillis(); | |
calculationTime = end - start; | |
isCalculatingHanoi = false; | |
Display.getInstance().callSerially(new Runnable(){ | |
public void run() { | |
towerOfHanoiLabel.setText("Calculation took "+calculationTime+"ms (counter "+h.counter+")"); | |
} | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment