def insert_from_sql(src_uri=None, query=None, fetch_size=100, concurrency=25, table=None, hosts=None, output_fmt=None): """Insert data read from another SQL source into table.""" stats = Stats() with clients.client(hosts, concurrency=concurrency) as client: f = partial(aio.measure, stats, client.execute_many) try: aio.run( async_insert_from_sql, src_uri, concurrency, query, fetch_size, table, f ) except clients.SqlException as e: raise SystemExit(str(e)) try: print(format_stats(stats.get(), output_fmt)) except KeyError: if not stats.sampler.values: raise SystemExit('No data read from source') raise
def test_short_result_output_with_only_1_measurement(self): stats = Stats(1) stats.measure(23.4) self.assertEqual( format_stats(stats.get(), 'short'), ('Runtime (in ms):\n' ' mean: 23.400 ± 0.000') )
def test_short_result_output_with_only_1_measurement(self): stats = Stats() stats.measure(23.4) self.assertEqual( format_stats(stats.get(), 'short'), ('Runtime (in ms):\n' ' mean: 23.400 ± 0.000') )
def test_short_result_output_with_more_measurements(self): stats = Stats(4) stats.measure(23.4) stats.measure(48.7) stats.measure(32.5) stats.measure(15.9) self.assertEqual(format_stats(stats.get(), 'short'), ('Runtime (in ms):\n' ' mean: 30.125 ± 13.839\n' ' min/max: 15.900 → 48.700\n' 'Percentile:\n' ' 50: 23.400 ± 14.121 (stdev)\n' ' 95: 48.700\n' ' 99.9: 48.700'))
def test_short_result_output_with_more_measurements(self): stats = Stats(4) stats.measure(23.4) stats.measure(48.7) stats.measure(32.5) stats.measure(15.9) self.assertEqual( format_stats(stats.get(), 'short'), ('Runtime (in ms):\n' ' mean: 30.125 ± 13.839\n' ' min/max: 15.900 → 48.700\n' 'Percentile:\n' ' 50: 23.400 ± 14.121 (stdev)\n' ' 95: 48.700\n' ' 99.9: 48.700') )