File: benchmark_registration.py

package info (click to toggle)
python-dtcwt 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,588 kB
  • sloc: python: 6,287; sh: 29; makefile: 13
file content (44 lines) | stat: -rwxr-xr-x 1,128 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python

from __future__ import print_function, division

import os
import sys
import textwrap
import timeit

# Add project root to path
sys.path.insert(0, os.path.realpath(os.path.join(os.path.dirname(__file__), '..')))

def main():
    t = timeit.Timer(
        setup=textwrap.dedent('''
            import dtcwt
            import dtcwt.registration
            import tests.datasets as datasets

            print('Loading datasets...')
            f1, f2 = datasets.regframes('tennis')

            print('Transforming datasets...')
            transform = dtcwt.Transform2d()
            t1 = transform.forward(f1, nlevels=6)
            t2 = transform.forward(f2, nlevels=6)
        '''),
        stmt=textwrap.dedent('''
            print('Registering datasets...')
            reg = dtcwt.registration.estimatereg(t1, t2)
        ''')
    )

    number = 20
    try:
        secs = t.timeit(number)
        print('{0:.2f}s for {1} iterations => {2:.2f}s/iteration'.format(
                secs, number, secs / number
            ))
    except:
        t.print_exc()

if __name__ == '__main__':
    main()