1648
|
1 import logging
|
1727
|
2 import unittest
|
1690
|
3 from typing import cast
|
1648
|
4
|
|
5 from rdflib.graph import ConjunctiveGraph
|
|
6
|
1727
|
7 from inference.inference import Inference
|
|
8 from inference.inference_test import N3
|
|
9 from inference.rdflib_debug_patches import patchBnodeCounter, patchSlimReprs
|
1648
|
10
|
1690
|
11 patchSlimReprs()
|
|
12 patchBnodeCounter(always=False)
|
|
13
|
|
14 logging.basicConfig(level=logging.DEBUG)
|
1648
|
15
|
|
16 # ~/.venvs/mqtt_to_rdf/bin/nosetests --with-watcher --logging-level=INFO --with-timer -s --nologcapture infer_perf_test
|
|
17
|
|
18
|
|
19 class TestPerf(unittest.TestCase):
|
|
20
|
|
21 def test(self):
|
|
22 config = ConjunctiveGraph()
|
|
23 config.parse('conf/rules.n3', format='n3')
|
|
24
|
|
25 inference = Inference()
|
|
26 inference.setRules(config)
|
|
27 expandedConfig = inference.infer(config)
|
|
28 expandedConfig += inference.nonRuleStatements()
|
1690
|
29 print(cast(bytes, expandedConfig.serialize(format='n3')).decode('utf8'))
|
|
30 self.fail()
|
1648
|
31
|
1661
|
32 for loop in range(50):
|
1648
|
33 # g = N3('''
|
|
34 # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ;
|
1661
|
35 # :body "online" ;
|
1648
|
36 # :onlineTerm :Online ;
|
|
37 # :topic ( "frontdoorlock" "status") .
|
|
38 # ''')
|
|
39 # derived = inference.infer(g)
|
|
40
|
|
41 # g = N3('''
|
|
42 # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ;
|
1661
|
43 # :body "zz" ;
|
1648
|
44 # :bodyFloat 12.2;
|
|
45 # :onlineTerm :Online ;
|
|
46 # :topic ( "air_quality_outdoor" "sensor" "bme280_temperature" "state") .
|
|
47 # ''')
|
|
48 # derived = inference.infer(g)
|
|
49 g = N3('''
|
|
50 <urn:uuid:a4778502-1784-11ec-a323-464f081581c1> a :MqttMessage ;
|
|
51 :body "65021" ;
|
|
52 :bodyFloat 6.5021e+04 ;
|
|
53 :topic ( "air_quality_indoor" "sensor" "ccs811_total_volatile_organic_compound" "state" ) .
|
|
54 ''')
|
|
55 derived = inference.infer(g)
|
|
56
|
|
57 # self.fail()
|