I’d suggest reading Performance Tips · The Julia Language, especially avoiding global non-constant variables like the plague, which is the very first recommendation.
For Chris’ benchmarks above I get
2.177121 seconds (4.16 M allocations: 235.169 MiB, 5.78% gc time, 99.36% compilation time)
0.168704 seconds (237.16 k allocations: 14.915 MiB, 27.91% gc time, 94.96% compilation time)
0.088142 seconds (227.82 k allocations: 13.500 MiB, 91.60% compilation time)
If I make all global variables constants (in a new session):
0.014117 seconds (82.83 k allocations: 10.422 MiB)
0.008273 seconds (9.25 k allocations: 1.430 MiB)
0.007206 seconds (39 allocations: 5.719 KiB)