|
@@ -16,6 +16,7 @@ DEFAULT_ITS = 20000
|
|
|
celery = Celery(__name__)
|
|
|
celery.conf.update(BROKER_TRANSPORT="librabbitmq",
|
|
|
BROKER_POOL_LIMIT=10,
|
|
|
+ CELERYD_POOL="solo",
|
|
|
CELERY_PREFETCH_MULTIPLIER=0,
|
|
|
CELERY_DISABLE_RATE_LIMITS=True,
|
|
|
#CELERY_DEFAULT_DELIVERY_MODE="transient",
|
|
@@ -45,7 +46,9 @@ def it(_, n):
|
|
|
if not i:
|
|
|
it.subt = it.time_start = time.time()
|
|
|
elif i == n - 1:
|
|
|
- print("-- process %s tasks: %ss" % (n, tdiff(it.time_start), ))
|
|
|
+ total = tdiff(it.time_start)
|
|
|
+ print("-- process %s tasks: %ss total, %s tasks/s} " % (
|
|
|
+ n, total, n / (total + .0)))
|
|
|
sys.exit()
|
|
|
it.cur += 1
|
|
|
|
|
@@ -59,7 +62,7 @@ def bench_apply(n=DEFAULT_ITS):
|
|
|
def bench_work(n=DEFAULT_ITS, loglevel=None):
|
|
|
if loglevel:
|
|
|
celery.log.setup_logging_subsystem(loglevel=loglevel)
|
|
|
- worker = celery.WorkController(concurrency=15, pool_cls="solo",
|
|
|
+ worker = celery.WorkController(concurrency=15,
|
|
|
queues=["bench.worker"])
|
|
|
|
|
|
try:
|
|
@@ -75,13 +78,19 @@ def bench_both(n=DEFAULT_ITS):
|
|
|
|
|
|
|
|
|
def main(argv=sys.argv):
|
|
|
+ n = DEFAULT_ITS
|
|
|
if len(argv) < 2:
|
|
|
- print("Usage: %s [apply|work|both]" % (os.path.basename(argv[0]), ))
|
|
|
+ print("Usage: %s [apply|work|both] [n=20k]" % (
|
|
|
+ os.path.basename(argv[0]), ))
|
|
|
return sys.exit(1)
|
|
|
try:
|
|
|
+ try:
|
|
|
+ n = int(argv[2])
|
|
|
+ except IndexError:
|
|
|
+ pass
|
|
|
return {"apply": bench_apply,
|
|
|
"work": bench_work,
|
|
|
- "both": bench_both}[argv[1]]()
|
|
|
+ "both": bench_both}[argv[1]](n=n)
|
|
|
except KeyboardInterrupt:
|
|
|
pass
|
|
|
|