mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Add sanity check for performance comparisons.
This commit is contained in:
@@ -6,8 +6,13 @@ import org.junit.Ignore;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanity check for {@link JdbcDatabasePerformanceComparisonTest}: check that
|
||||||
|
* if conditions A and B are identical, no significant difference is (usually)
|
||||||
|
* detected.
|
||||||
|
*/
|
||||||
@Ignore
|
@Ignore
|
||||||
public class H2DatabasePerformanceSelfComparisonTest
|
public class H2SelfDatabasePerformanceComparisonTest
|
||||||
extends JdbcDatabasePerformanceComparisonTest {
|
extends JdbcDatabasePerformanceComparisonTest {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.briarproject.bramble.db;
|
||||||
|
|
||||||
|
import org.briarproject.bramble.api.db.DatabaseConfig;
|
||||||
|
import org.briarproject.bramble.api.db.DbException;
|
||||||
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
|
import org.junit.Ignore;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanity check for {@link JdbcDatabasePerformanceComparisonTest}: check that
|
||||||
|
* if condition B sleeps for 1ms before every commit, condition A is
|
||||||
|
* considered to be faster.
|
||||||
|
*/
|
||||||
|
@Ignore
|
||||||
|
public class H2SleepDatabasePerformanceComparisonTest
|
||||||
|
extends JdbcDatabasePerformanceComparisonTest {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Database<Connection> createDatabase(boolean conditionA,
|
||||||
|
DatabaseConfig databaseConfig, Clock clock) {
|
||||||
|
if (conditionA) {
|
||||||
|
return new H2Database(databaseConfig, clock);
|
||||||
|
} else {
|
||||||
|
return new H2Database(databaseConfig, clock) {
|
||||||
|
@Override
|
||||||
|
@NotNullByDefault
|
||||||
|
public void commitTransaction(Connection txn)
|
||||||
|
throws DbException {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new DbException(e);
|
||||||
|
}
|
||||||
|
super.commitTransaction(txn);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getTestName() {
|
||||||
|
return getClass().getSimpleName();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user