File: progress.session

package info (click to toggle)
regina-normal 4.1.3-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 12,072 kB
  • ctags: 5,069
  • sloc: cpp: 43,186; sh: 8,427; perl: 2,363; makefile: 828; python: 114
file content (64 lines) | stat: -rw-r--r-- 2,074 bytes parent folder | download | duplicates (4)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
example$ regina-python
Regina 4.1.3
A Normal Surface Theory Calculator
Copyright (c) 1999-2004, Ben Burton
>>> ################################
... #
... #  Sample Python Script
... #
... #  Illustrates progress reporting during long operations.
... #
... #  See the file "progress.session" for the results of running this script.
... #
... ################################
...
>>> import time
>>>
>>> # Create a new triangulation of the lens space L(49,12).
... tri = regina.NTriangulation()
>>> tri.insertLayeredLensSpace(49,12)
>>> print tri.getNumberOfTetrahedra(), 'tetrahedra'
13 tetrahedra
>>>
>>> # Create a progress manager to use during the lengthy surface enumeration.
... # This will be responsible for reporting the state of progress while the
... # enumeration runs in the background.
... manager = regina.NProgressManager()
>>>
>>> # Start the normal surface enumeration.
... # Because we are passing a progress manager to enumerate(), the
... # enumeration will be started in the background and control will be
... # returned immediately to the python console.
... surfaces = regina.NNormalSurfaceList.enumerate(tri,
...     regina.NNormalSurfaceList.STANDARD, 1, manager)
>>>
>>> # Wait for the surface enumeration to fully start up.
... while not manager.isStarted():
...     time.sleep(1)
...
>>>
>>> # At this point the surface enumeration is now running.
... # Output a progress report every second until it's finished.
... prog = manager.getProgress()
>>> while not manager.isFinished():
...     print 'Progress:', prog.getDescription()
...     time.sleep(1)
...
Progress: 4/81
Progress: 60/81
Progress: 68/81
Progress: 73/81
Progress: 74/81
Progress: 74/81
Progress: 77/81
>>>
>>> # The surface enumeration is now complete.
... print surfaces.getNumberOfSurfaces(), 'normal surfaces'
432 normal surfaces
>>>
>>> # Output the total time spent during the surface enumeration.
... print 'Total real time:', prog.getRealTime(), 'seconds'
Total real time: 6 seconds
>>> print 'Total cpu time:', prog.totalCPUTime(), 'seconds'
Total cpu time: 6 seconds
>>>