Skip to content
Snippets Groups Projects
Commit bb69c30c authored by René Schöne's avatar René Schöne
Browse files

Better tracing.

- added script to push event file to local influxdb
parent ef24ec8d
No related branches found
No related tags found
1 merge request!1All4one relast
/src/gen/
/src/gen-res/
/build/
events.txt
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""Tutorial how to use the class helper `SeriesHelper`."""
import csv
from datetime import datetime
import re
import os
import sys
from influxdb import InfluxDBClient
from influxdb import SeriesHelper
# InfluxDB connections settings
host = '172.22.1.152'
port = 8086
user = ''
password = ''
dbname = 'jastadd'
myclient = InfluxDBClient(host, port, user, password, dbname)
# Uncomment the following code if the database is not yet created
myclient.drop_database(dbname)
myclient.create_database(dbname)
# myclient.create_retention_policy('awesome_policy', '3d', 3, default=True)
class MySeriesHelper(SeriesHelper):
"""Instantiate SeriesHelper to write points to the backend."""
class Meta:
"""Meta class stores time series helper configuration."""
# The client should be an instance of InfluxDBClient.
client = myclient
# The series name must be a string. Add dependent fields/tags
# in curly brackets.
series_name = 'ttc18live'
# Defines all the fields in this time series.
fields = ['dummy']
# Defines all the tags for the series.
tags = ['event', 'attribute', 'size', 'query']
# Defines the number of data points to store prior to writing
# on the wire.
bulk_size = 10000
# autocommit must be set to True when using bulk_size
autocommit = True
def nice_tag(s):
s = s.replace('.', '_')
s = re.sub(r'\([^)]*\)', '', s)
return s
def main(filename, size, query):
fieldnames = ['timestamp'] + MySeriesHelper.Meta.tags[:] + MySeriesHelper.Meta.fields[:]
# read <filename> (or solve/<filename> if not found. maybe we are in root directory after all)
if not os.path.exists(filename):
filename = os.path.join('solve', filename)
with open(filename) as fdr:
reader = csv.DictReader(fdr, fieldnames=fieldnames)
for row in reader:
dt = datetime.fromtimestamp(long(row['timestamp']) / 1000.0)
MySeriesHelper(time=dt.strftime('%Y-%m-%dT%H:%M:%S.%fZ'),
event=nice_tag(row['event']),
attribute=nice_tag(row["attribute"]),
size=size,
query=query,
dummy='1')
# print MySeriesHelper._json_body_()
# 1/0
# print MySeriesHelper._json_body_()
# To manually submit data points which are not yet written, call commit:
MySeriesHelper.commit()
# To inspect the JSON which will be written, call _json_body_():
# print MySeriesHelper._json_body_()
if __name__ == '__main__':
if len(sys.argv) <= 3:
print 'Usage: %s <path/to/csv> <size> <query>' % sys.argv[0]
sys.exit(0)
filename, size, query = sys.argv[1:]
main(filename, size, query)
......@@ -6,8 +6,10 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;
import java.nio.file.Path;
/**
* TODO: Add description.
* Abstract Driver for a JastAdd solution.
*
* @author rschoene - Initial contribution
*/
......@@ -23,6 +25,14 @@ public abstract class AbstractLiveContestDriver {
private static long stopwatch;
private static Solution solution;
private boolean traceEvents;
private Path pathOfEventFile;
AbstractLiveContestDriver enableTracing(Path pathOfEventFile) {
this.pathOfEventFile = pathOfEventFile;
this.traceEvents = true;
return this;
}
enum BenchmarkPhase {
Initialization,
......@@ -44,8 +54,12 @@ public abstract class AbstractLiveContestDriver {
for (int i = 1; i <= Sequences; i++) {
Update(i);
}
if (traceEvents) {
solution.getSocialNetwork().writeTracingEvents(pathOfEventFile);
}
System.err.println();
} catch (Exception e) {
System.err.println();
e.printStackTrace();
}
}
......@@ -58,6 +72,14 @@ public abstract class AbstractLiveContestDriver {
return solution;
}
static String getChangeSet() {
return ChangeSet;
}
static String getQuery() {
return Query;
}
private void Initialize() throws Exception {
stopwatch = System.nanoTime();
ChangePath = System.getenv("ChangePath");
......@@ -87,7 +109,9 @@ public abstract class AbstractLiveContestDriver {
stopwatch = System.nanoTime();
SocialNetwork socialNetwork = LoadImpl();
if (traceEvents) {
socialNetwork.enableTracing();
}
solution.setSocialNetwork(socialNetwork);
stopwatch = System.nanoTime() - stopwatch;
......@@ -97,7 +121,9 @@ public abstract class AbstractLiveContestDriver {
abstract SocialNetwork LoadImpl() throws Exception;
public void Initial() {
if (traceEvents) {
solution.getSocialNetwork().insertCustomEvent("TTC_INITIAL", ChangeSet);
}
stopwatch = System.nanoTime();
String result = solution.Initial();
stopwatch = System.nanoTime() - stopwatch;
......@@ -109,10 +135,14 @@ public abstract class AbstractLiveContestDriver {
System.err.print(iteration + " ");
String size_iteration = ChangeSet + Integer.toString(iteration);
if (traceEvents) {
solution.getSocialNetwork().insertCustomEvent("TTC_TRANSFORMATION", size_iteration);
}
ModelChangeSet modelChangeSet = UpdateImpl(iteration);
if (traceEvents) {
solution.getSocialNetwork().insertCustomEvent("TTC_RECHECK", size_iteration);
}
stopwatch = System.nanoTime();
String result = solution.Update(modelChangeSet);
stopwatch = System.nanoTime() - stopwatch;
......@@ -121,8 +151,7 @@ public abstract class AbstractLiveContestDriver {
abstract ModelChangeSet UpdateImpl(int iteration) throws Exception;
private void Report(BenchmarkPhase phase, int iteration, String result)
{
private void Report(BenchmarkPhase phase, int iteration, String result) {
String iterationStr;
if (iteration == -1) {
iterationStr = "0";
......@@ -137,8 +166,7 @@ public abstract class AbstractLiveContestDriver {
Runtime.getRuntime().gc();
long memoryUsed = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.out.println(String.format("%s;%s;%s;%s;%s;%s;Memory;%s", Tool, Query, ChangeSet, RunIndex, iterationStr, phase.toString(), Long.toString(memoryUsed)));
if (result != null)
{
if (result != null) {
System.out.println(String.format("%s;%s;%s;%s;%s;%s;Elements;%s", Tool, Query, ChangeSet, RunIndex, iterationStr, phase.toString(), result));
}
}
......
......@@ -16,6 +16,7 @@ import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
......@@ -29,8 +30,9 @@ import java.util.Map;
public class LiveContestDriverEMF extends AbstractLiveContestDriver {
public static void main(String[] args) throws IOException {
// Path filename = Paths.get(String.format("events-emf-%s-%s.csv", getChangeSet(), getQuery()));
// new LiveContestDriverEMF().enableTracing(filename).mainImpl();
new LiveContestDriverEMF().mainImpl();
getSolution().getSocialNetwork().writeTracingEvents(Paths.get("events-emf.csv"));
}
private static ResourceSet repository;
......
......@@ -19,9 +19,9 @@ import java.nio.file.Paths;
* @author jmey - Implementation of 2nd query
*/
public class LiveContestDriverXml extends AbstractLiveContestDriver {
public static void main(String[] args) throws IOException {
new LiveContestDriverXml().mainImpl();
getSolution().getSocialNetwork().writeTracingEvents(Paths.get("events-xml.csv"));
public static void main(String[] args) {
Path filename = Paths.get(String.format("events-xml-%s-%s.csv", getChangeSet(), getQuery()));
new LiveContestDriverXml().enableTracing(filename).mainImpl();
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment