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 |
---|
9 | big_array = xrange(int(1e6)) |
---|
10 | |
---|
11 | # the do-it-yourself way |
---|
12 | from time import time |
---|
13 | t = time() |
---|
14 | result = [i**2 for i in big_array] |
---|
15 | print "Time: %s" % (time() - t) |
---|
16 | |
---|
17 | # import the timing decorator... |
---|
18 | from timer import timed |
---|
19 | |
---|
20 | @timed(verbose=False) |
---|
21 | def square_me(x): |
---|
22 | return [i**2 for i in x] |
---|
23 | |
---|
24 | # time the function call using the @timed function |
---|
25 | result = square_me(big_array) |
---|
26 | print "Timed: %s" % square_me.time() |
---|
Note: See
TracBrowser
for help on using the repository browser.