-
Notifications
You must be signed in to change notification settings - Fork 3
/
versions_benchmark.sh
executable file
·62 lines (54 loc) · 2.57 KB
/
versions_benchmark.sh
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
# Ensure we don't write bytecode to __pycache__
export PYTHONDONTWRITEBYTECODE=1
echo "1. Permission vs. forgiveness"
echo "Permission 1 attribute:"
python -m timeit -s "from permission_vs_forgiveness import test_permission" "test_permission()"
echo "Forgiveness 1 attribute:"
python -m timeit -s "from permission_vs_forgiveness import test_forgiveness" "test_forgiveness()"
echo "Permission 3 attributes:"
python -m timeit -s "from permission_vs_forgiveness2 import test_permission" "test_permission()"
echo "Forgiveness 3 attributes:"
python -m timeit -s "from permission_vs_forgiveness2 import test_forgiveness" "test_forgiveness()"
echo "Permission missing attribute:"
python -m timeit -s "from permission_vs_forgiveness3 import test_permission" "test_permission()"
echo "Forgiveness missing attribute:"
python -m timeit -s "from permission_vs_forgiveness3 import test_forgiveness" "test_forgiveness()"
echo "\n2. Find element"
echo "While loop:"
python -m timeit -s "from find_element import while_loop" "while_loop()"
echo "For loop:"
python -m timeit -s "from find_element import for_loop" "for_loop()"
echo "List comprehension:"
python -m timeit -s "from find_element import list_comprehension" "list_comprehension()"
echo "Generator:"
python -m timeit -s "from find_element import generator" "generator()"
echo "\n3. Filter list"
echo "Loop:"
python -m timeit -s "from filter_list import test_loop" "test_loop()"
echo "Filter:"
python -m timeit -s "from filter_list import test_filter" "test_filter()"
echo "Comprehension:"
python -m timeit -s "from filter_list import test_comprehension" "test_comprehension()"
echo "\n4. Membership (checking number 500,000 in a 1,000,000 numbers list)"
echo "For loop:"
python -m timeit -s "from membership import test_for_loop" "test_for_loop(500_000)"
echo "In list:"
python -m timeit -s "from membership import test_in" "test_in(500_000)"
echo "In set (cheating):"
python -m timeit -s "from membership2 import test_in_set" "test_in_set(500_000)"
echo "In set (proper):"
python -m timeit -s "from membership2 import test_in_set_proper" "test_in_set_proper(500_000)"
echo "\n5. dict() vs. {}"
echo "dict()"
python -m timeit "a = dict()"
echo "{}"
python -m timeit "a = {}"
echo "\n6. Remove duplicates"
echo "For loop:"
python -m timeit -s "from duplicates import test_for_loop" "test_for_loop()"
echo "List comprehension:"
python -m timeit -s "from duplicates import test_list_comprehension" "test_list_comprehension()"
echo "Set:"
python -m timeit -s "from duplicates import test_set" "test_set()"
echo "Dict:"
python -m timeit -s "from duplicates import test_dict" "test_dict()"