예제 #1
0
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
예제 #2
0
파일: test_engine.py 프로젝트: ynuosoft/cr8
 def test_fail_if_supports_runtime_stats(self):
     stats = Stats()
     stats.measure(103.2)
     stats.measure(205.2)
     timed_stats = TimedStats(1, 2, stats)
     result = Result({}, 'select name', timed_stats, 1)
     with self.assertRaises(FailIf):
         eval_fail_if("{runtime_stats.max} > 30", result)
예제 #3
0
파일: test_log.py 프로젝트: chaudum/cr8
 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')
     )
예제 #4
0
파일: test_log.py 프로젝트: ynuosoft/cr8
 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')
     )
예제 #5
0
def run_and_measure(f, statements, concurrency, num_items=None, sampler=None):
    stats = Stats(sampler)
    measure = partial(aio.measure, stats, f)
    started = int(time() * 1000)
    aio.run_many(measure, statements, concurrency, num_items=num_items)
    ended = int(time() * 1000)
    return TimedStats(started, ended, stats)
예제 #6
0
 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'))
예제 #7
0
파일: test_log.py 프로젝트: chaudum/cr8
 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')
     )
예제 #8
0
 def test_fail_if_fails(self):
     timed_stats = TimedStats(1, 2, Stats())
     result = Result({}, 'select name', timed_stats, 1)
     with self.assertRaises(FailIf):
         eval_fail_if("'{statement}' == 'select name'", result)
예제 #9
0
파일: test_engine.py 프로젝트: ynuosoft/cr8
 def test_fail_if_supports_bulk_size(self):
     stats = Stats()
     timed_stats = TimedStats(1, 2, stats)
     result = Result({}, 'select name', timed_stats, 1, bulk_size=200)
     eval_fail_if("{bulk_size} < 200", result)
예제 #10
0
파일: test_engine.py 프로젝트: ynuosoft/cr8
 def test_fail_if_supports_concurrency(self):
     stats = Stats()
     timed_stats = TimedStats(1, 2, stats)
     result = Result({}, 'select name', timed_stats, 1)
     with self.assertRaises(FailIf):
         eval_fail_if("{concurrency} == 1", result)