timing an application's setup ?

26 views
Skip to first unread message

Jonathan Vanasco

unread,
Mar 21, 2015, 2:33:57 PM3/21/15
to pylons-...@googlegroups.com
Has anyone figured out a way to time an application's setup?

I'm interested in the total time from the process being invoked until it's ready to serve.

The ApplicationCreated event seems to be a good "finish" time, but I can't figure out a good "start" time to include the overhead of whatever process starts the server (ie, the time between calling `pserve` and application file being processed ).


Oliver Berger

unread,
Mar 21, 2015, 6:40:35 PM3/21/15
to pylons-...@googlegroups.com
What about
import os, psutil

t1
= psutil.Process(os.getpid()).create_time


Jonathan Vanasco

unread,
Mar 23, 2015, 11:09:13 AM3/23/15
to pylons-...@googlegroups.com
That works PERFECT!  thanks!

    from pyramid.events import ApplicationCreated, subscriber
    import os
    import psutil
    import time

    def application_created(event):
        time_now = time.time()
        time_start = psutil.Process(os.getpid()).create_time()
        print "-----------------------------"
        print "STARTED AT : %s" % time_start
        print "READY AT   : %s" % time_now
        print "TOOK       : %s" % (time_now - time_start)
        print "-----------------------------"

Reply all
Reply to author
Forward
0 new messages