Mercurial > code > home > repos > homeauto
diff service/mqtt_to_rdf/infer_perf_test.py @ 1648:3059f31b2dfa
more performance work
author | drewp@bigasterisk.com |
---|---|
date | Fri, 17 Sep 2021 11:10:18 -0700 |
parents | |
children | 00a5624d1d14 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/service/mqtt_to_rdf/infer_perf_test.py Fri Sep 17 11:10:18 2021 -0700 @@ -0,0 +1,50 @@ +import logging +import unittest + +from rdflib.graph import ConjunctiveGraph + +from inference import Inference +from inference_test import N3 + +logging.basicConfig(level=logging.INFO) + +# ~/.venvs/mqtt_to_rdf/bin/nosetests --with-watcher --logging-level=INFO --with-timer -s --nologcapture infer_perf_test + + +class TestPerf(unittest.TestCase): + + def test(self): + config = ConjunctiveGraph() + config.parse('conf/rules.n3', format='n3') + + inference = Inference() + inference.setRules(config) + expandedConfig = inference.infer(config) + expandedConfig += inference.nonRuleStatements() + + for loop in range(10): + # g = N3(''' + # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ; + # :body "online" ; + # :onlineTerm :Online ; + # :topic ( "frontdoorlock" "status") . + # ''') + # derived = inference.infer(g) + + # g = N3(''' + # <urn:uuid:2f5bbe1e-177f-11ec-9f97-8a12f6515350> a :MqttMessage ; + # :body "zz" ; + # :bodyFloat 12.2; + # :onlineTerm :Online ; + # :topic ( "air_quality_outdoor" "sensor" "bme280_temperature" "state") . + # ''') + # derived = inference.infer(g) + g = N3(''' + <urn:uuid:a4778502-1784-11ec-a323-464f081581c1> a :MqttMessage ; + :body "65021" ; + :bodyFloat 6.5021e+04 ; + :topic ( "air_quality_indoor" "sensor" "ccs811_total_volatile_organic_compound" "state" ) . + ''') + derived = inference.infer(g) + + # self.fail()