A
A
Alexey Belov2019-02-12 10:03:34
Python
Alexey Belov, 2019-02-12 10:03:34

How to find out the execution time of celery tasks?

How to find the execution time of the Celerial tasks, for example, I have 10 pictures, I create a task.delay () in a loop, how to find out the execution time of 10 tasks, well, or at least one to start

def perfomance():
  if request.method == 'GET':
    start = timer()
    results = []
    for path in glob.glob('/home/alenorze/Workspace/Django/hair_backend/test_data/*.jpeg'):
      task = create_mask.delay(path)
      result = AsyncResult(task.id)
      results.append(result)
    end = timer()
    time = end - start
  return render_template('ex.html', time=time, result=result)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BJlaDuMup, 2019-02-12
@BJlaDuMup

from time import time as timer


def perfomance():
  if request.method == 'GET':
    start = timer()
    results = []
    for path in glob.glob('/home/alenorze/Workspace/Django/hair_backend/test_data/*.jpeg'):
      task = create_mask.delay(path)
      result = AsyncResult(task.id)
      results.append(result)
    end = timer()
    time = end - start
  return render_template('ex.html', time=time, result=result)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question