From ebcff08692adfb37d8216fc6caace0d61c8e52e9 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Mon, 9 Nov 2020 10:36:25 +0000 Subject: [PATCH] add performance timer to the correction --- perguntations/app.py | 4 ++-- perguntations/serve.py | 16 +++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/perguntations/app.py b/perguntations/app.py index 533046a..525acb0 100644 --- a/perguntations/app.py +++ b/perguntations/app.py @@ -224,8 +224,8 @@ class App(): ''' Corrects test - ans is a dictionary {question_index: answer, ...} - for example: {0:'hello', 1:[1,2]} + ans is a dictionary {question_index: answer, ...} with the answers for + the complete test. For example: {0:'hello', 1:[1,2]} ''' test = self.online[uid]['test'] diff --git a/perguntations/serve.py b/perguntations/serve.py index d76dddd..47cc656 100644 --- a/perguntations/serve.py +++ b/perguntations/serve.py @@ -7,15 +7,16 @@ Uses the tornadoweb framework. # python standard library -from os import path -import sys import base64 -import uuid +import functools +import json import logging.config import mimetypes +from os import path import signal -import functools -import json +import sys +from timeit import default_timer as timer +import uuid # user installed libraries import tornado.ioloop @@ -421,6 +422,7 @@ class TestHandler(BaseHandler): builds dictionary ans={0: 'answer0', 1:, 'answer1', ...} unanswered questions not included. ''' + timeit_start = timer() # performance timer uid = self.current_user test = self.testapp.get_student_test(uid) @@ -447,6 +449,10 @@ class TestHandler(BaseHandler): # show final grade and grades of other tests in the database allgrades = self.testapp.get_student_grades_from_all_tests(uid) + + timeit_finish = timer() + logging.info(' correction took %fs', timeit_finish-timeit_start) + self.render('grade.html', t=test, allgrades=allgrades) -- libgit2 0.21.2