diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2019-07-24 17:04:47 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2019-07-24 17:04:47 +0200 |
commit | 06d4b31d438c69dd47164c3661f3497fb5e869cb (patch) | |
tree | fcfbba3d3ea13008d3a1374066654034dbf19410 /test | |
parent | cc0302ffae75c6ece528bb3dd8d3cbee8c8c2492 (diff) |
add simple AnalyticModel test
Diffstat (limited to 'test')
-rwxr-xr-x | test/onboardtimingharness-to-analytic-model.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/onboardtimingharness-to-analytic-model.py b/test/onboardtimingharness-to-analytic-model.py new file mode 100755 index 0000000..ed908c5 --- /dev/null +++ b/test/onboardtimingharness-to-analytic-model.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python3 + +from dfatool import AnalyticModel, TimingData, pta_trace_to_aggregate +import unittest + +class TestModels(unittest.TestCase): + def test_model_singlefile_rf24(self): + raw_data = TimingData(['../data/20190724_161440_nRF24_no-rx.json']) + preprocessed_data = raw_data.get_preprocessed_data(verbose = False) + by_name, parameters, arg_count = pta_trace_to_aggregate(preprocessed_data) + model = AnalyticModel(by_name, parameters, verbose = False) + self.assertEqual(model.names, 'setAutoAck setPALevel setRetries setup startListening stopListening write'.split(' ')) + static_model = model.get_static() + self.assertAlmostEqual(static_model('setAutoAck', 'duration'), 72, places=0) + self.assertAlmostEqual(static_model('setPALevel', 'duration'), 145, places=0) + self.assertAlmostEqual(static_model('setRetries', 'duration'), 72, places=0) + self.assertAlmostEqual(static_model('setup', 'duration'), 6464, places=0) + self.assertAlmostEqual(static_model('startListening', 'duration'), 455, places=0) + self.assertAlmostEqual(static_model('stopListening', 'duration'), 487, places=0) + self.assertAlmostEqual(static_model('write', 'duration'), 5877, places=0) + + for transition in 'setAutoAck setPALevel setRetries setup startListening stopListening'.split(' '): + self.assertAlmostEqual(model.stats.param_dependence_ratio(transition, 'duration', 'channel'), 0, places=2) + + +if __name__ == '__main__': + unittest.main() |