Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ protected Object prepare( ChronosJob chronosJob, final File inputDirectory, fina
// Parse CDL
Map<String, String> parsedConfig = parseConfig( chronosJob );

if ( !parsedConfig.containsKey( "queryMode" ) ) {
throw new RuntimeException( "Query mode not specified" );
}

switch ( parsedConfig.get( "queryMode" ) ) {
case "Table":
queryMode = QueryMode.TABLE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.util.Collection;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicLong;
import lombok.extern.slf4j.Slf4j;
import org.polypheny.simpleclient.query.QueryListEntry;
Expand Down Expand Up @@ -70,21 +71,21 @@ public static class ReportQueryListProgress implements Runnable {

private final int totalNumber;
private final ProgressReporter theProgressReporter;
private final List<QueryListEntry> theList;
private final Queue<QueryListEntry> theQueue;


public ReportQueryListProgress( List<QueryListEntry> list, ProgressReporter progressReporter ) {
public ReportQueryListProgress( Queue<QueryListEntry> list, ProgressReporter progressReporter ) {
this.totalNumber = list.size();
this.theList = list;
this.theQueue = list;
this.theProgressReporter = progressReporter;
}


@Override
public void run() {
while ( true ) {
theProgressReporter.update( totalNumber - theList.size(), totalNumber );
if ( theList.isEmpty() ) {
theProgressReporter.update( totalNumber - theQueue.size(), totalNumber );
if ( theQueue.isEmpty() ) {
break;
}
try {
Expand All @@ -97,7 +98,7 @@ public void run() {


public void updateProgress() {
theProgressReporter.update( totalNumber - theList.size(), totalNumber );
theProgressReporter.update( totalNumber - theQueue.size(), totalNumber );
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Getter;
Expand All @@ -43,7 +44,7 @@
public class EvaluationThread extends Thread {

private final Executor executor;
private final List<QueryListEntry> queries;
private final Queue<QueryListEntry> queries;
private boolean abort = false;
@Setter
private EvaluationThreadMonitor threadMonitor;
Expand All @@ -55,7 +56,7 @@ public class EvaluationThread extends Thread {
final boolean commitAfterEveryQuery;


public EvaluationThread( List<QueryListEntry> queryList, Executor executor, Set<Integer> templateIds, boolean commitAfterEveryQuery ) {
public EvaluationThread( Queue<QueryListEntry> queryList, Executor executor, Set<Integer> templateIds, boolean commitAfterEveryQuery ) {
super( "EvaluationThread" );
this.executor = executor;
this.queries = queryList;
Expand All @@ -72,11 +73,8 @@ public void run() {

while ( !queries.isEmpty() && !abort ) {
measuredTimeStart = System.nanoTime();
try {
queryListEntry = queries.removeFirst();
} catch ( IndexOutOfBoundsException e ) { // This is neither nice nor efficient...
// This can happen due to concurrency if two threads enter the while-loop and there is only one thread left
// Simply leaf the loop
queryListEntry = queries.poll();
if ( queryListEntry == null ) {
break;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Queue;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Function;
import java.util.function.Supplier;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -61,11 +63,13 @@ public PolyphenyScenario( JdbcExecutor.ExecutorFactory executorFactory, boolean
}


protected long commonExecute( List<QueryListEntry> queryList, ProgressReporter progressReporter, File outputDirectory, int numberOfThreads, Function<Query, String> toString, Supplier<Executor> executor, Random random ) {
Collections.shuffle( queryList, random );
protected long commonExecute( List<QueryListEntry> queries, ProgressReporter progressReporter, File outputDirectory, int numberOfThreads, Function<Query, String> toString, Supplier<Executor> executor, Random random ) {
Collections.shuffle( queries, random );

// This dumps the queries independent of the selected interface
dumpQueryList( outputDirectory, queryList, toString );
dumpQueryList( outputDirectory, queries, toString );

Queue<QueryListEntry> queryList = new ConcurrentLinkedQueue<>( queries );

log.info( "Executing benchmark..." );
(new Thread( new ProgressReporter.ReportQueryListProgress( queryList, progressReporter ) )).start();
Expand Down
22 changes: 2 additions & 20 deletions src/main/java/org/polypheny/simpleclient/scenario/Scenario.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

import com.google.common.base.Joiner;
import java.io.File;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.util.List;
import java.util.LongSummaryStatistics;
import java.util.Map;
Expand Down Expand Up @@ -101,17 +99,9 @@ protected void calculateResults( Map<Integer, String> queryTypes, Properties pro


protected double calculateMean( List<Long> times ) {
DecimalFormat df = new DecimalFormat( "0.000" );
OptionalDouble meanOptional = times.stream().mapToLong( Long::longValue ).average();
if ( meanOptional.isPresent() ) {
// scale
double mean = meanOptional.getAsDouble() / 1000000.0;
String roundFormat = df.format( mean );
try {
return df.parse( roundFormat ).doubleValue();
} catch ( ParseException e ) {
log.error( "Exception", e );
}
return Math.round( meanOptional.getAsDouble() / 1_000 ) / 1_000.0;
}
return -1;
}
Expand All @@ -125,15 +115,7 @@ protected double calculateSampleStandardDeviation( List<Long> times, double mean


protected double processDoubleValue( double value ) {
DecimalFormat df = new DecimalFormat( "0.000" );
double temp1 = value / 1_000_000;
String roundFormat = df.format( temp1 );
try {
return df.parse( roundFormat ).doubleValue();
} catch ( ParseException e ) {
log.error( "Exception", e );
}
return -1;
return Math.round( value / 1_000 ) / 1_000.0;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.List;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -276,7 +277,7 @@ private void startEvaluation( ProgressReporter progressReporter, CsvWriter csvWr

ArrayList<EvaluationThread> threads = new ArrayList<>();
for ( List<QueryListEntry> queryList : organized ) {
threads.add( new EvaluationThread( queryList, executorFactory.createExecutorInstance( csvWriter, NAMESPACE ), queryTypes.keySet(), commitAfterEveryQuery ) );
threads.add( new EvaluationThread( new ConcurrentLinkedQueue<>( queryList ), executorFactory.createExecutorInstance( csvWriter, NAMESPACE ), queryTypes.keySet(), commitAfterEveryQuery ) );
}

EvaluationThreadMonitor threadMonitor = new EvaluationThreadMonitor( threads );
Expand Down