diff options
author | OszkarSemerath <oszka@152.66.252.189> | 2017-07-05 16:39:07 +0200 |
---|---|---|
committer | OszkarSemerath <oszka@152.66.252.189> | 2017-07-05 16:39:07 +0200 |
commit | 57fd631100fffc26da8a1de2de3cb8b00c4e8370 (patch) | |
tree | 76be751913aa2243e28f629977cab0d870e35ad9 /Tests/hu.bme.mit.inf.dslreasoner.run | |
parent | Example configuration for running measurements. (diff) | |
download | VIATRA-Generator-57fd631100fffc26da8a1de2de3cb8b00c4e8370.tar.gz VIATRA-Generator-57fd631100fffc26da8a1de2de3cb8b00c4e8370.tar.zst VIATRA-Generator-57fd631100fffc26da8a1de2de3cb8b00c4e8370.zip |
Pattern coverage measuring program.
Diffstat (limited to 'Tests/hu.bme.mit.inf.dslreasoner.run')
-rw-r--r-- | Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MeasurePatternCoverage.xtend | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MeasurePatternCoverage.xtend b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MeasurePatternCoverage.xtend new file mode 100644 index 00000000..99ea6e9d --- /dev/null +++ b/Tests/hu.bme.mit.inf.dslreasoner.run/src/hu/bme/mit/inf/dslreasoner/run/MeasurePatternCoverage.xtend | |||
@@ -0,0 +1,73 @@ | |||
1 | package hu.bme.mit.inf.dslreasoner.run | ||
2 | |||
3 | import hu.bme.mit.inf.dslreasoner.domains.yakindu.sgraph.yakindumm.YakindummPackage | ||
4 | import java.io.File | ||
5 | import java.util.LinkedList | ||
6 | import java.util.List | ||
7 | import org.eclipse.emf.common.util.URI | ||
8 | import org.eclipse.emf.ecore.EObject | ||
9 | import org.eclipse.emf.ecore.resource.Resource | ||
10 | import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl | ||
11 | import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl | ||
12 | import org.eclipse.viatra.query.runtime.api.ViatraQueryEngine | ||
13 | import org.eclipse.viatra.query.runtime.emf.EMFScope | ||
14 | |||
15 | class MeasurePatternCoverage { | ||
16 | |||
17 | static def void init() { | ||
18 | YakindummPackage.eINSTANCE.eClass | ||
19 | Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("*", new XMIResourceFactoryImpl()); | ||
20 | } | ||
21 | |||
22 | static def List<String> loadAllModelPathsInDirectory(String path) { | ||
23 | val File directory = new File(path); | ||
24 | if(directory.exists() && directory.isDirectory()) { | ||
25 | val filePaths = new LinkedList | ||
26 | for(File f : directory.listFiles()) { | ||
27 | if(f.isFile()) { | ||
28 | val filePath = f.getPath(); | ||
29 | if(filePath.endsWith("xmi")) { | ||
30 | filePaths.add(filePath); | ||
31 | } | ||
32 | } | ||
33 | } | ||
34 | return filePaths; | ||
35 | } else { | ||
36 | throw new IllegalArgumentException("invalid path"); | ||
37 | } | ||
38 | } | ||
39 | |||
40 | static def EObject loadModel(String path) { | ||
41 | val rs = new ResourceSetImpl | ||
42 | val resource = rs.getResource(URI.createFileURI(path), true); | ||
43 | return resource.getContents().get(0); | ||
44 | } | ||
45 | |||
46 | |||
47 | def static void main(String[] args) { | ||
48 | init() | ||
49 | val allModelPaths = loadAllModelPathsInDirectory("D:\\Eclipse\\GIT\\fmhe-analysis\\models-renamed") | ||
50 | val wfPatternsWOSynch = hu.bme.mit.inf.dslreasoner.partialsnapshot_mavo.yakindu.Patterns.instance.specifications | ||
51 | .filter[spec | | ||
52 | !YakinduLoader::patternsWithSynchronization.exists[spec.fullyQualifiedName.endsWith(it)] | ||
53 | ].filter[ | ||
54 | it.allAnnotations.exists[it.name== "Constraint"] | ||
55 | ].toList | ||
56 | |||
57 | println('''type;id;«FOR pattern : wfPatternsWOSynch SEPARATOR ";"»«pattern.fullyQualifiedName»«ENDFOR»''') | ||
58 | for(modelPath : allModelPaths) { | ||
59 | //println(modelPath) | ||
60 | val model = loadModel(modelPath) | ||
61 | val engine = ViatraQueryEngine.on(new EMFScope(model)) | ||
62 | val fileName = modelPath.split("\\\\") | ||
63 | val fileNameWOExtension = fileName.last.split("\\.").head | ||
64 | val fileNameSegments = fileNameWOExtension.split("_") | ||
65 | print('''«fileNameSegments.get(0)»;«fileNameSegments.get(1)»''') | ||
66 | for(pattern : wfPatternsWOSynch) { | ||
67 | val matcher = pattern.getMatcher(engine) | ||
68 | print(''';«matcher.countMatches»''') | ||
69 | } | ||
70 | println() | ||
71 | } | ||
72 | } | ||
73 | } \ No newline at end of file | ||