adamantike | 0756a9c | 2016-01-24 21:19:17 -0300 | [diff] [blame^] | 1 | #!/bin/bash |
Roy Kokkelkoren | 0659aac | 2015-10-25 16:12:11 +0100 | [diff] [blame] | 2 | # |
| 3 | # Copyright 2011 Sybren A. Stüvel <sybren@stuvel.eu> |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
Yesudeep Mangalapilly | a4453c6 | 2011-08-11 12:03:37 +0530 | [diff] [blame] | 16 | |
adamantike | 0756a9c | 2016-01-24 21:19:17 -0300 | [diff] [blame^] | 17 | # Checks if a command is available on the system. |
| 18 | check_command() { |
| 19 | # Return with error, if not called with just one argument. |
| 20 | if [ "$#" != 1 ]; then |
| 21 | echo "ERROR: Incorrect usage of function 'check_program'." 1>&2 |
| 22 | echo " Correct usage: check_command COMMAND" 1>&2 |
| 23 | return 1 |
| 24 | fi |
| 25 | # Check command availability. |
| 26 | command -v "$1" >/dev/null 2>&1 |
| 27 | } |
| 28 | |
| 29 | python_versions=" |
| 30 | pypy |
| 31 | python2.5 |
| 32 | python2.6 |
| 33 | python2.7 |
| 34 | python3.2 |
| 35 | python3.3 |
| 36 | python3.4 |
| 37 | python3.5 |
| 38 | " |
| 39 | |
Yesudeep Mangalapilly | a4453c6 | 2011-08-11 12:03:37 +0530 | [diff] [blame] | 40 | echo "int2bytes speed test" |
adamantike | 0756a9c | 2016-01-24 21:19:17 -0300 | [diff] [blame^] | 41 | for version in $python_versions; do |
| 42 | if check_command "$version"; then |
| 43 | echo "$version" |
| 44 | "$version" -mtimeit -s'from rsa.transform import int2bytes; n = 1<<4096' 'int2bytes(n)' |
| 45 | "$version" -mtimeit -s'from rsa.transform import _int2bytes; n = 1<<4096' '_int2bytes(n)' |
| 46 | fi |
| 47 | done |
Yesudeep Mangalapilly | 8132524 | 2011-08-12 13:06:51 +0530 | [diff] [blame] | 48 | |
Yesudeep Mangalapilly | ce4ede7 | 2011-08-12 15:29:31 +0530 | [diff] [blame] | 49 | echo "bit_size speed test" |
adamantike | 0756a9c | 2016-01-24 21:19:17 -0300 | [diff] [blame^] | 50 | for version in $python_versions; do |
| 51 | if check_command "$version"; then |
| 52 | echo "$version" |
| 53 | "$version" -mtimeit -s'from rsa.common import bit_size; n = 1<<4096' 'bit_size(n)' |
| 54 | "$version" -mtimeit -s'from rsa.common import _bit_size; n = 1<<4096' '_bit_size(n)' |
| 55 | fi |
| 56 | done |