How to use _format_values method in Slash

Best Python code snippet using slash

benchmark_results_unittest.py

Source:benchmark_results_unittest.py Github

copy

Full Screen

...56SomeTest:Time:Arithmetic: 3.0ms stdev=33.3%57 :Time:Total: 7.0ms stdev=28.6%58'''[1:])59 def test_format_values_with_large_error(self):60 self.assertEqual(BenchmarkResults._format_values('Runs', [1, 2, 3]), '2.0/s stdev=50.0%')61 self.assertEqual(BenchmarkResults._format_values('Runs', [10, 20, 30]), '20/s stdev=50.0%')62 self.assertEqual(BenchmarkResults._format_values('Runs', [100, 200, 300]), '200/s stdev=50.0%')63 self.assertEqual(BenchmarkResults._format_values('Runs', [1000, 2000, 3000]), '2.0K/s stdev=50.0%')64 self.assertEqual(BenchmarkResults._format_values('Runs', [10000, 20000, 30000]), '20K/s stdev=50.0%')65 self.assertEqual(BenchmarkResults._format_values('Runs', [100000, 200000, 300000]), '200K/s stdev=50.0%')66 self.assertEqual(BenchmarkResults._format_values('Runs', [1000000, 2000000, 3000000]), '2.0M/s stdev=50.0%')67 self.assertEqual(BenchmarkResults._format_values('Runs', [0.1, 0.2, 0.3]), '200m/s stdev=50.0%')68 self.assertEqual(BenchmarkResults._format_values('Runs', [0.01, 0.02, 0.03]), '20m/s stdev=50.0%')69 self.assertEqual(BenchmarkResults._format_values('Runs', [0.001, 0.002, 0.003]), '2.0m/s stdev=50.0%')70 self.assertEqual(BenchmarkResults._format_values('Runs', [0.0001, 0.0002, 0.0003]), '200u/s stdev=50.0%')71 self.assertEqual(BenchmarkResults._format_values('Runs', [0.00001, 0.00002, 0.00003]), '20u/s stdev=50.0%')72 self.assertEqual(BenchmarkResults._format_values('Runs', [0.000001, 0.000002, 0.000003]), '2.0u/s stdev=50.0%')73 def test_format_values_with_small_error(self):74 self.assertEqual(BenchmarkResults._format_values('Runs', [1.1, 1.2, 1.3]), '1.20/s stdev=8.3%')75 self.assertEqual(BenchmarkResults._format_values('Runs', [11, 12, 13]), '12.0/s stdev=8.3%')76 self.assertEqual(BenchmarkResults._format_values('Runs', [110, 120, 130]), '120/s stdev=8.3%')77 self.assertEqual(BenchmarkResults._format_values('Runs', [1100, 1200, 1300]), '1.20K/s stdev=8.3%')78 self.assertEqual(BenchmarkResults._format_values('Runs', [11000, 12000, 13000]), '12.0K/s stdev=8.3%')79 self.assertEqual(BenchmarkResults._format_values('Runs', [110000, 120000, 130000]), '120K/s stdev=8.3%')80 self.assertEqual(BenchmarkResults._format_values('Runs', [1100000, 1200000, 1300000]), '1.20M/s stdev=8.3%')81 self.assertEqual(BenchmarkResults._format_values('Runs', [0.11, 0.12, 0.13]), '120m/s stdev=8.3%')82 self.assertEqual(BenchmarkResults._format_values('Runs', [0.011, 0.012, 0.013]), '12.0m/s stdev=8.3%')83 self.assertEqual(BenchmarkResults._format_values('Runs', [0.0011, 0.0012, 0.0013]), '1.20m/s stdev=8.3%')84 self.assertEqual(BenchmarkResults._format_values('Runs', [0.00011, 0.00012, 0.00013]), '120u/s stdev=8.3%')85 self.assertEqual(BenchmarkResults._format_values('Runs', [0.000011, 0.000012, 0.000013]), '12.0u/s stdev=8.3%')86 self.assertEqual(BenchmarkResults._format_values('Runs', [0.0000011, 0.0000012, 0.0000013]), '1.20u/s stdev=8.3%')87 def test_format_values_with_time(self):88 self.assertEqual(BenchmarkResults._format_values('Time', [1, 2, 3]), '2.0ms stdev=50.0%')89 self.assertEqual(BenchmarkResults._format_values('Time', [10, 20, 30]), '20ms stdev=50.0%')90 self.assertEqual(BenchmarkResults._format_values('Time', [100, 200, 300]), '200ms stdev=50.0%')91 self.assertEqual(BenchmarkResults._format_values('Time', [1000, 2000, 3000]), '2.0s stdev=50.0%')92 self.assertEqual(BenchmarkResults._format_values('Time', [10000, 20000, 30000]), '20s stdev=50.0%')93 self.assertEqual(BenchmarkResults._format_values('Time', [100000, 200000, 300000]), '200s stdev=50.0%')94 self.assertEqual(BenchmarkResults._format_values('Time', [0.11, 0.12, 0.13]), '120us stdev=8.3%')95 self.assertEqual(BenchmarkResults._format_values('Time', [0.011, 0.012, 0.013]), '12.0us stdev=8.3%')96 self.assertEqual(BenchmarkResults._format_values('Time', [0.0011, 0.0012, 0.0013]), '1.20us stdev=8.3%')97 self.assertEqual(BenchmarkResults._format_values('Time', [0.00011, 0.00012, 0.00013]), '120ns stdev=8.3%')98 def test_format_values_with_no_unit_scaling(self):99 self.assertEqual(BenchmarkResults._format_values('Runs', [1, 2, 3], scale_unit=False), '2.000/s stdev=50.0%')100 self.assertEqual(BenchmarkResults._format_values('Runs', [10, 20, 30], scale_unit=False), '20.000/s stdev=50.0%')101 self.assertEqual(BenchmarkResults._format_values('Runs', [100, 200, 300], scale_unit=False), '200.000/s stdev=50.0%')102 self.assertEqual(BenchmarkResults._format_values('Runs', [1000, 2000, 3000], scale_unit=False), '2000.000/s stdev=50.0%')103 self.assertEqual(BenchmarkResults._format_values('Runs', [10000, 20000, 30000], scale_unit=False), '20000.000/s stdev=50.0%')104 self.assertEqual(BenchmarkResults._format_values('Runs', [100000, 200000, 300000], scale_unit=False), '200000.000/s stdev=50.0%')105 self.assertEqual(BenchmarkResults._format_values('Runs', [1000000, 2000000, 3000000], scale_unit=False), '2000000.000/s stdev=50.0%')106 self.assertEqual(BenchmarkResults._format_values('Runs', [0.1, 0.2, 0.3], scale_unit=False), '0.200/s stdev=50.0%')107 self.assertEqual(BenchmarkResults._format_values('Runs', [0.01, 0.02, 0.03], scale_unit=False), '0.020/s stdev=50.0%')108 self.assertEqual(BenchmarkResults._format_values('Runs', [0.001, 0.002, 0.003], scale_unit=False), '0.002/s stdev=50.0%')109 self.assertEqual(BenchmarkResults._format_values('Runs', [0.0001, 0.0002, 0.0003], scale_unit=False), '0.000/s stdev=50.0%')110 self.assertEqual(BenchmarkResults._format_values('Runs', [0.00001, 0.00002, 0.00003], scale_unit=False), '0.000/s stdev=50.0%')111 self.assertEqual(BenchmarkResults._format_values('Runs', [0.000001, 0.000002, 0.000003], scale_unit=False), '0.000/s stdev=50.0%')112 def test_format_values_with_iteration_values(self):113 self.assertEqual(BenchmarkResults._format_values('Time', [1, 2, 3], show_iteration_values=True), '2.0ms stdev=50.0% [1.0, 2.0, 3.0]')114 self.assertEqual(BenchmarkResults._format_values('Time', [10, 20, 30], show_iteration_values=True), '20ms stdev=50.0% [10, 20, 30]')115 self.assertEqual(BenchmarkResults._format_values('Time', [100, 200, 300], show_iteration_values=True), '200ms stdev=50.0% [100, 200, 300]')116 self.assertEqual(BenchmarkResults._format_values('Time', [1000, 2000, 3000], show_iteration_values=True), '2.0s stdev=50.0% [1.0, 2.0, 3.0]')117 self.assertEqual(BenchmarkResults._format_values('Time', [10000, 20000, 30000], show_iteration_values=True), '20s stdev=50.0% [10, 20, 30]')118 self.assertEqual(BenchmarkResults._format_values('Time', [100000, 200000, 300000], show_iteration_values=True), '200s stdev=50.0% [100, 200, 300]')119 self.assertEqual(BenchmarkResults._format_values('Time', [0.11, 0.12, 0.13], show_iteration_values=True), '120us stdev=8.3% [110, 120, 130]')120 self.assertEqual(BenchmarkResults._format_values('Time', [0.011, 0.012, 0.013], show_iteration_values=True), '12.0us stdev=8.3% [11.0, 12.0, 13.0]')121 self.assertEqual(BenchmarkResults._format_values('Time', [0.0011, 0.0012, 0.0013], show_iteration_values=True), '1.20us stdev=8.3% [1.10, 1.20, 1.30]')122 self.assertEqual(BenchmarkResults._format_values('Time', [0.00011, 0.00012, 0.00013], show_iteration_values=True), '120ns stdev=8.3% [110, 120, 130]')123 def test_format_values_with_no_unit_scaling_and_iteration_values(self):124 self.assertEqual(BenchmarkResults._format_values('Runs', [1, 2, 3], scale_unit=False, show_iteration_values=True),125 '2.000/s stdev=50.0% [1.000, 2.000, 3.000]')126 self.assertEqual(BenchmarkResults._format_values('Runs', [100, 200, 300], scale_unit=False, show_iteration_values=True),127 '200.000/s stdev=50.0% [100.000, 200.000, 300.000]')128 self.assertEqual(BenchmarkResults._format_values('Runs', [1000, 2000, 3000], scale_unit=False, show_iteration_values=True),129 '2000.000/s stdev=50.0% [1000.000, 2000.000, 3000.000]')130 self.assertEqual(BenchmarkResults._format_values('Runs', [1000000, 2000000, 3000000], scale_unit=False, show_iteration_values=True),131 '2000000.000/s stdev=50.0% [1000000.000, 2000000.000, 3000000.000]')132 self.assertEqual(BenchmarkResults._format_values('Runs', [0.1, 0.2, 0.3], scale_unit=False, show_iteration_values=True),133 '0.200/s stdev=50.0% [0.100, 0.200, 0.300]')134 self.assertEqual(BenchmarkResults._format_values('Runs', [0.0001, 0.0002, 0.0003], scale_unit=False, show_iteration_values=True),135 '0.000/s stdev=50.0% [0.000, 0.000, 0.000]')136 def test_format_values_with_no_error(self):137 self.assertEqual(BenchmarkResults._format_values('Time', [1, 1, 1]), '1.00ms stdev=0.0%')138 def test_format_values_with_small_difference(self):139 self.assertEqual(BenchmarkResults._format_values('Time', [5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4]),140 '4.05ms stdev=5.5%')141 def test_aggregate_results(self):142 self.maxDiff = None143 self.assertEqual(BenchmarkResults._aggregate_results(144 {'SomeTest': {'metrics': {'Time': {'current': [1, 2, 3]}}}}),145 {'SomeTest': {'metrics': {'Time': {None: {'current': [1, 2, 3]}}}, 'tests': {}}})146 self.assertEqual(BenchmarkResults._aggregate_results(147 {'SomeTest': {148 'metrics': {'Time': ['Total']},149 'tests': {150 'SubTest1': {'metrics': {'Time': {'current': [1, 2, 3]}}},151 'SubTest2': {'metrics': {'Time': {'current': [4, 5, 6]}}}}}}),152 {'SomeTest': {153 'metrics': {'Time': {'Total': {'current': [5, 7, 9]}}},...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful