use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.
the class DSN method newScanner.
public TestScanner newScanner() throws Exception {
SpecScanner specScanner = new SpecScanner();
List<Constraint> l = specScanner.scan();
Bench.mode = Bench.Mode.REPLAY;
return new TestScanner(l);
}
use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.
the class DSN method funcFrequency.
// @Test
public void funcFrequency() throws Exception {
SpecScanner sc = new SpecScanner();
List<Constraint> l = sc.scan();
Pattern p = Pattern.compile("([a-zA-Z]+\\()+");
Map<String, Integer> map = new HashMap<>();
for (Constraint c : l) {
String prop = c.proposition().toString();
Matcher m = p.matcher(prop);
System.out.println(prop);
int start = 0;
while (m.find(start)) {
String name = prop.substring(m.start(), m.end() - 1);
if (Character.isLowerCase(name.charAt(0))) {
if (!map.containsKey(name)) {
map.put(name, 1);
} else {
map.put(name, map.get(name) + 1);
}
}
System.out.println("\t" + prop.substring(m.start(), m.end() - 1));
start = m.end();
}
}
System.out.println(map);
Path out = Paths.get(root, "func-freq.csv");
Files.deleteIfExists(out);
String cnt = "name;freq\n" + map.entrySet().stream().map(e -> e.getKey() + ";" + e.getValue() + "\n").collect(Collectors.joining());
Files.write(out, cnt.getBytes());
}
use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.
the class TestSafePlace method launcher.
// @Test
public void launcher() throws Exception {
SpecScanner specScanner = new SpecScanner();
List<Constraint> l = specScanner.scan();
TestScanner sc = new TestScanner(l);
List<TestCampaign> campaigns = sc.test(TestSafePlace.class);
// List<TestCampaign> campaigns = sc.testGroups("_resourceCapacity");
if (campaigns.isEmpty()) {
Assert.fail("Nothing to test");
}
campaigns.forEach(tc -> {
// .setVerbosity(1);
tc.schedulerParams().doRepair(false);
tc.onDefect(DefectHooks.ignore);
tc.limits().clear().tests(1000);
System.out.println(tc.go());
});
}
use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.
the class DSN method specLength.
// @Test
public void specLength() throws Exception {
SpecScanner sc = new SpecScanner();
List<Constraint> l = sc.scan();
System.out.println(l.stream().map(Constraint::pretty).collect(Collectors.joining("\n")));
Path path = Paths.get(root, "inv.csv");
String out = l.stream().map(c -> Integer.toString(c.proposition().toString().length())).collect(Collectors.joining("\n"));
Files.write(path, out.getBytes());
List<Integer> funcs = new ArrayList<>();
List<Path> paths = Files.list(Paths.get("safeplace/src/main/java/org/btrplace/safeplace/spec/term/func")).filter(Files::isRegularFile).collect(Collectors.toList());
for (Path p : paths) {
try (InputStream in = Files.newInputStream(p)) {
CompilationUnit cu = JavaParser.parse(in);
new FunctionVisitor(funcs).visit(cu, null);
}
}
path = Paths.get(root, "func.csv");
out = funcs.stream().map(c -> Integer.toString(c)).collect(Collectors.joining("\n"));
Files.write(path, out.getBytes());
}
use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.
the class TestScannerTest method newScanner.
public TestScanner newScanner() throws Exception {
SpecScanner specScanner = new SpecScanner();
List<Constraint> l = specScanner.scan();
return new TestScanner(l);
}
Aggregations