blob: e06d8252096e3165f3fa77bb66372de8b45f4447 [file] [log] [blame]
Sybren A. Stüvelea145922016-01-25 12:45:20 +01001#!/bin/bash -e
Roy Kokkelkoren0659aac2015-10-25 16:12:11 +01002#
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#
Sybren A. Stüvel3934ab42016-02-05 16:01:20 +01009# https://www.apache.org/licenses/LICENSE-2.0
Roy Kokkelkoren0659aac2015-10-25 16:12:11 +010010#
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 Mangalapillya4453c62011-08-11 12:03:37 +053016
adamantike0756a9c2016-01-24 21:19:17 -030017# Checks if a command is available on the system.
18check_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
29python_versions="
30 pypy
adamantike0756a9c2016-01-24 21:19:17 -030031 python2.7
adamantike0756a9c2016-01-24 21:19:17 -030032 python3.4
33 python3.5
34"
35
Yesudeep Mangalapillya4453c62011-08-11 12:03:37 +053036echo "int2bytes speed test"
adamantike0756a9c2016-01-24 21:19:17 -030037for version in $python_versions; do
38 if check_command "$version"; then
39 echo "$version"
40 "$version" -mtimeit -s'from rsa.transform import int2bytes; n = 1<<4096' 'int2bytes(n)'
41 "$version" -mtimeit -s'from rsa.transform import _int2bytes; n = 1<<4096' '_int2bytes(n)'
42 fi
43done