source: branches/decorate/test_timer.py @ 855

Revision 855, 724 bytes checked in by mmckerns, 5 months ago (diff)

updated copyright to 2016

Line 
1#!/usr/bin/env python
2#
3# Author: Mike McKerns (mmckerns @caltech and @uqfoundation)
4# Copyright (c) 2012-2016 California Institute of Technology.
5# License: 3-clause BSD.  The full license text is available at:
6#  - http://mmckerns.github.io/project/mystic/browser/mystic/LICENSE
7
8# create a big array of data
9big_array = xrange(int(1e6))
10
11# the do-it-yourself way
12from time import time
13t = time()
14result = [i**2 for i in big_array]
15print "Time:  %s" % (time() - t)
16
17# import the timing decorator...
18from timer import timed
19
20@timed(verbose=False)
21def square_me(x):
22    return [i**2 for i in x]
23
24# time the function call using the @timed function
25result = square_me(big_array)
26print "Timed: %s" % square_me.time()
Note: See TracBrowser for help on using the repository browser.