Skip to content

Instantly share code, notes, and snippets.

@Altai-man
Last active July 30, 2019 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Altai-man/307a095d3e05265cf470238a243bd8af to your computer and use it in GitHub Desktop.
Save Altai-man/307a095d3e05265cf470238a243bd8af to your computer and use it in GitHub Desktop.
my $total-re = 0;
for ^10_000_000 {
my $x = 5 + 2i;
my $y = 10 + 3i;
my $z = $x * $x + $y;
$total-re = $total-re + $z.re
}
total = 0;
i = 0;
while i < 10000000:
x = 5 + complex(0, 2)
y = 10 + complex(0, 3)
z = x * x + y
total = total + z.real
i += 1
[koto@dispair ~]$ python3 --version
Python 3.6.9
[koto@dispair ~]$ perl6 --version
This is Rakudo version 2019.07 built on MoarVM version 2019.07
implementing Perl 6.d.
[koto@dispair ~]$ cat /proc/cpuinfo | grep name
model name : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
model name : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
model name : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
model name : Intel(R) Core(TM) i7-7500U CPU @ 2.70GHz
[koto@dispair ~]$ cat python3.py
total = 0;
i = 0;
while i < 10000000:
x = 5 + complex(0, 2)
y = 10 + complex(0, 3)
z = x * x + y
total = total + z.real
i += 1
[koto@dispair ~]$ time python3 python3.py
real 0m8.207s
user 0m8.170s
sys 0m0.012s
[koto@dispair ~]$ cat perl6.p6
my $total-re = 0;
for ^10_000_000 {
my $x = 5 + 2i;
my $y = 10 + 3i;
my $z = $x * $x + $y;
$total-re = $total-re + $z.re
}
[koto@dispair ~]$ time perl6 perl6.p6
real 0m3.192s
user 0m3.210s
sys 0m0.032s
[koto@dispair ~]$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment