File: multibench.py

package info (click to toggle)
ceph 18.2.7%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,186,140 kB
  • sloc: cpp: 6,278,388; ansic: 3,507,431; python: 372,964; asm: 216,381; java: 133,450; sh: 125,043; xml: 39,398; ruby: 32,026; makefile: 29,004; javascript: 23,994; cs: 18,980; perl: 9,708; sql: 7,833; lisp: 5,920; pascal: 3,109; ada: 1,681; yacc: 478; awk: 188; f90: 55; php: 1
file content (61 lines) | stat: -rw-r--r-- 1,511 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
Multibench testing
"""
import contextlib
import logging
import time
import copy
import gevent

from tasks import radosbench

log = logging.getLogger(__name__)

@contextlib.contextmanager
def task(ctx, config):
    """
    Run multibench

    The config should be as follows:

    multibench:
        time: <seconds to run total>
        segments: <number of concurrent benches>
        radosbench: <config for radosbench>

    example:

    tasks:
    - ceph:
    - multibench:
        clients: [client.0]
        time: 360
    - interactive:
    """
    log.info('Beginning multibench...')
    assert isinstance(config, dict), \
        "please list clients to run on"

    def run_one(num):
        """Run test spawn from gevent"""
        start = time.time()
        if not config.get('radosbench'):
            benchcontext = {}
        else:
            benchcontext = copy.copy(config.get('radosbench'))
        iterations = 0
        while time.time() - start < int(config.get('time', 600)):
            log.info("Starting iteration %s of segment %s"%(iterations, num))
            benchcontext['pool'] = str(num) + "-" + str(iterations)
            with radosbench.task(ctx, benchcontext):
                time.sleep()
            iterations += 1
    log.info("Starting %s threads"%(str(config.get('segments', 3)),))
    segments = [
        gevent.spawn(run_one, i)
        for i in range(0, int(config.get('segments', 3)))]

    try:
        yield
    finally:
        [i.get() for i in segments]