Skip to content

Instantly share code, notes, and snippets.

@ckaminski
Created April 17, 2014 15:24
Show Gist options
  • Save ckaminski/10991769 to your computer and use it in GitHub Desktop.
Save ckaminski/10991769 to your computer and use it in GitHub Desktop.
SysPropTest - demonstrates how long it takes a particular java runtime to iterate through one billion invocations of System.getProperty(). There's possibly some efficiencies in this tight loop, so this is a best case. Authored to test likely impact of a planned Property adapter/facade.
import java.lang.*;
public class SysPropTest {
public static void main(String[] args) {
final String propName = "com.example.test.PropertyName";
long start = System.currentTimeMillis();
for (int i = 0; i < 1000000000; i++ ) {
String val = System.getProperty(propName);
val = "abcdef";
}
long end = System.currentTimeMillis();
long diff = end - start;
System.out.println("ElapsedTime = " + Long.toString(diff) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment