Example #1
0
# Copyright 2015 Nir Soffer <*****@*****.**>
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v2 or (at your option) any later version.

import optparse
import sys
import benchlib

parser = benchlib.option_parser("sleepless [options]")
parser.add_option("-s",
                  "--timeout",
                  dest="timeout",
                  type="float",
                  help="number of seconds to sleep")
parser.set_defaults(threads=400, timeout=10)


def sleepless(options):
    import threading

    cond = threading.Condition(threading.Lock())
    threads = []

    for i in benchlib.range(options.threads):
        t = threading.Thread(target=sleep, args=(cond, options.timeout))
        t.daemon = True
        t.start()
        threads.append(t)
Example #2
0
# Copyright 2015 Nir Soffer <*****@*****.**>
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v2 or (at your option) any later version.

import optparse
import sys
import benchlib

parser = benchlib.option_parser("whispers [options]")
parser.add_option("-j", "--jobs", dest="jobs", type="int",
                  help="number of jobs")
parser.set_defaults(threads=200, jobs=5000)


def whispers(options):
    import threading
    try:
        import Queue as queue
    except ImportError:
        import queue

    leftmost = queue.Queue()
    left = leftmost
    for i in benchlib.range(options.threads):
        right = queue.Queue()
        t = threading.Thread(target=whisper, args=(left, right))
        t.daemon = True
        t.start()
        left = right
Example #3
0
# Copyright 2015 Nir Soffer <*****@*****.**>
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v2 or (at your option) any later version.

import optparse
import sys
import benchlib

parser = benchlib.option_parser("sleepless [options]")
parser.add_option("-s", "--timeout", dest="timeout", type="float",
                  help="number of seconds to sleep")
parser.set_defaults(threads=400, timeout=10)


def sleepless(options):
    import threading

    cond = threading.Condition(threading.Lock())
    threads = []

    for i in benchlib.range(options.threads):
        t = threading.Thread(target=sleep, args=(cond, options.timeout))
        t.daemon = True
        t.start()
        threads.append(t)

    for t in threads:
        t.join()
Example #4
0
# Copyright 2015 Nir Soffer <*****@*****.**>
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v2 or (at your option) any later version.

import optparse
import sys
import benchlib

parser = benchlib.option_parser("threadpool [options]")
parser.add_option("-j", "--jobs", dest="jobs", type="int",
                  help="number of jobs to queue")
parser.add_option("-r", "--rounds", dest="rounds", type="int",
                  help="number of rounds")
parser.set_defaults(threads=20, jobs=3000, rounds=200)


def threadpool(options):
    import threading

    try:
        import Queue as queue
    except ImportError:
        import queue

    src = queue.Queue()
    dst = queue.Queue()

    for i in benchlib.range(options.threads):
        t = threading.Thread(target=worker, args=(src, dst))