What would be the best method for comparing insertions when performance testing multiple db's?
I'm currently using ThreadMXBean to check how long the CPU is spending on a certain method. (source)
public static void main(String[] args) throws FileNotFoundException, IOException, ParseException, InterruptedException {
conn = r.connection().hostname("localhost").port(28015).connect();
r.db("test").table("users").delete();
JSONParser parser = new JSONParser();
Object obj = parser.parse(new FileReader("C:/Documents/SmallUsersFile.json"));
JSONArray jsonObject = (JSONArray) obj;
start();
insertSmallFile(jsonObject);
stop();
System.out.println("Duration: " + getCpuTimeInMillis());
conn.close();
}
public static void insertSmallFile(JSONArray jsonObject) throws FileNotFoundException, IOException, ParseException {
r.db("test").table("users").insert(jsonObject).run(conn);
}
public static void start() {
_startTime = getCpuTimeInMillis();
}
public static long stop() {
long result = (getCpuTimeInMillis() - _startTime);
_startTime = 0l;
return result;
}
public static boolean isRunning() {
return _startTime != 0l;
}
private static long getCpuTimeInMillis() {
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
return bean.isCurrentThreadCpuTimeSupported() ? bean.getCurrentThreadCpuTime() / 1000000 : 0L;
}
But I'm unsure if the actual insertion into the database is being measured or simply how long it took to execute the method. Does the thread wait until it gets an OK back?