Added a profiler, which outputs time taken and calls to various functions.
[ipdf/code.git] / tools / NumericalOperationsPerformanceTests.ipynb
1 {
2  "metadata": {
3   "name": ""
4  },
5  "nbformat": 3,
6  "nbformat_minor": 0,
7  "worksheets": [
8   {
9    "cells": [
10     {
11      "cell_type": "markdown",
12      "metadata": {},
13      "source": [
14       "## Test the performance of numerical operations"
15      ]
16     },
17     {
18      "cell_type": "code",
19      "collapsed": false,
20      "input": [
21       "%pylab inline"
22      ],
23      "language": "python",
24      "metadata": {},
25      "outputs": [
26       {
27        "output_type": "stream",
28        "stream": "stdout",
29        "text": [
30         "Populating the interactive namespace from numpy and matplotlib\n"
31        ]
32       }
33      ],
34      "prompt_number": 1
35     },
36     {
37      "cell_type": "code",
38      "collapsed": false,
39      "input": [
40       "from common import *"
41      ],
42      "language": "python",
43      "metadata": {},
44      "outputs": [],
45      "prompt_number": 14
46     },
47     {
48      "cell_type": "code",
49      "collapsed": false,
50      "input": [
51       "for b in [\"single\", \"double\", \"GMPrat\", \"ParanoidNumber\"]:\n",
52       "    os.system(\"make -C %s clean\" % options[\"ipdf_src\"])\n",
53       "    os.system(\"make -C %s REALTYPE=%d tests/identitytests\" % (options[\"ipdf_src\"], options[\"real_names\"].index(b)))\n",
54       "    os.system(\"mv %s/tests/identitytests %s/identity-%s\" % (options[\"ipdf_src\"], options[\"local_bin\"], b))\n",
55       "    display(\"Built %s\" % b)"
56      ],
57      "language": "python",
58      "metadata": {},
59      "outputs": [
60       {
61        "metadata": {},
62        "output_type": "display_data",
63        "text": [
64         "'Built single'"
65        ]
66       },
67       {
68        "metadata": {},
69        "output_type": "display_data",
70        "text": [
71         "'Built double'"
72        ]
73       },
74       {
75        "metadata": {},
76        "output_type": "display_data",
77        "text": [
78         "'Built GMPrat'"
79        ]
80       },
81       {
82        "metadata": {},
83        "output_type": "display_data",
84        "text": [
85         "'Built ParanoidNumber'"
86        ]
87       }
88      ],
89      "prompt_number": 26
90     },
91     {
92      "cell_type": "code",
93      "collapsed": false,
94      "input": [
95       "def IdentityTest(real):\n",
96       "    start = time.time()\n",
97       "    display(\"%s starts at %d\" % (b, start))\n",
98       "    p = subprocess.Popen(\"./identity-%s\" % real, bufsize=0, stdin=subprocess.PIPE, \\\n",
99       "                         stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\n",
100       "    p.wait()\n",
101       "    display(\"%s completed, took %d\" % (real,time.time() - start))\n",
102       "    "
103      ],
104      "language": "python",
105      "metadata": {},
106      "outputs": [],
107      "prompt_number": 30
108     },
109     {
110      "cell_type": "code",
111      "collapsed": false,
112      "input": [
113       "import threading"
114      ],
115      "language": "python",
116      "metadata": {},
117      "outputs": [],
118      "prompt_number": 31
119     },
120     {
121      "cell_type": "code",
122      "collapsed": false,
123      "input": [
124       "for b in [\"single\", \"double\", \"GMPrat\", \"ParanoidNumber\"]:\n",
125       "    threading.Thread(target=IdentityTest, args=(b,)).start()"
126      ],
127      "language": "python",
128      "metadata": {},
129      "outputs": [
130       {
131        "metadata": {},
132        "output_type": "display_data",
133        "text": [
134         "'double starts at 1411243678'"
135        ]
136       },
137       {
138        "metadata": {},
139        "output_type": "display_data",
140        "text": [
141         "'GMPrat starts at 1411243678'"
142        ]
143       },
144       {
145        "metadata": {},
146        "output_type": "display_data",
147        "text": [
148         "'ParanoidNumber starts at 1411243678'"
149        ]
150       }
151      ],
152      "prompt_number": 33
153     },
154     {
155      "cell_type": "code",
156      "collapsed": false,
157      "input": [],
158      "language": "python",
159      "metadata": {},
160      "outputs": []
161     }
162    ],
163    "metadata": {}
164   }
165  ]
166 }

UCC git Repository :: git.ucc.asn.au