Last active
January 12, 2017 14:13
-
-
Save mafredri/93b01fd0384a737da213e6b9bba205a6 to your computer and use it in GitHub Desktop.
Quick performance test for setting a variable via capturing output to sub-shell vs a typeset in the running function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== RUN test_bench_print_subshell_05 | |
--- PASS: test_bench_print_subshell_05 (0.02s) | |
=== RUN test_bench_print_subshell_10 | |
--- PASS: test_bench_print_subshell_10 (0.02s) | |
=== RUN test_bench_print_subshell_100 | |
--- PASS: test_bench_print_subshell_100 (0.14s) | |
=== RUN test_bench_print_subshell_1000 | |
--- PASS: test_bench_print_subshell_1000 (0.79s) | |
=== RUN test_bench_typeset_var_05 | |
--- PASS: test_bench_typeset_var_05 (0.00s) | |
=== RUN test_bench_typeset_var_10 | |
--- PASS: test_bench_typeset_var_10 (0.00s) | |
=== RUN test_bench_typeset_var_100 | |
--- PASS: test_bench_typeset_var_100 (0.00s) | |
=== RUN test_bench_typeset_var_1000 | |
--- PASS: test_bench_typeset_var_1000 (0.01s) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_print() { | |
print "Hello world" | |
} | |
set_typeset() { | |
typeset -g "$1"="Hello world" | |
} | |
test_bench_print_subshell_05() { | |
local var | |
for i in {1..5}; do | |
var=$(set_print) | |
done | |
} | |
test_bench_print_subshell_10() { | |
local var | |
for i in {1..10}; do | |
var=$(set_print) | |
done | |
} | |
test_bench_print_subshell_100() { | |
local var | |
for i in {1..100}; do | |
var=$(set_print) | |
done | |
} | |
test_bench_print_subshell_1000() { | |
local var | |
for i in {1..1000}; do | |
var=$(set_print) | |
done | |
} | |
test_bench_typeset_var_05() { | |
local var | |
for i in {1..5}; do | |
set_typeset var | |
done | |
} | |
test_bench_typeset_var_10() { | |
local var | |
for i in {1..10}; do | |
set_typeset var | |
done | |
} | |
test_bench_typeset_var_100() { | |
local var | |
for i in {1..100}; do | |
set_typeset var | |
done | |
} | |
test_bench_typeset_var_1000() { | |
local var | |
for i in {1..1000}; do | |
set_typeset var | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment