Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
ThePrimeBenchMark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nimrod
ThePrimeBenchMark
Commits
c795373a
Commit
c795373a
authored
9 years ago
by
nimrod
Browse files
Options
Downloads
Patches
Plain Diff
Added special cases for Python3, Python, PyPy and LuaJIT.
parent
437ffd2f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Makefile
+4
-1
4 additions, 1 deletion
Makefile
prime.py
+6
-2
6 additions, 2 deletions
prime.py
with
10 additions
and
3 deletions
Makefile
+
4
−
1
View file @
c795373a
...
@@ -18,8 +18,11 @@ clean:
...
@@ -18,8 +18,11 @@ clean:
test
:
all
test
:
all
@
time
-f
"%C : %E seconds"
./a.out
$(
ROUNDS
)
>
/dev/null
@
time
-f
"%C : %E seconds"
./a.out
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which python3
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.py
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which python
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.py
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which python3
)
"
]
&&
time
-f
"%C : %E seconds"
python3 prime.py
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which pypy
)
"
]
&&
time
-f
"%C : %E seconds"
pypy prime.py
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which lua
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.lua
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which lua
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.lua
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which luajit
)
"
]
&&
time
-f
"%C : %E seconds"
luajit prime.lua
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which php
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.php
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which php
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.php
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which php7.0
)
"
]
&&
time
-f
"%C : %E seconds"
php7.0 prime.php
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which php7.0
)
"
]
&&
time
-f
"%C : %E seconds"
php7.0 prime.php
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which ruby
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.rb
$(
ROUNDS
)
>
/dev/null
@
[
-n
"
$$(
which ruby
)
"
]
&&
time
-f
"%C : %E seconds"
./prime.rb
$(
ROUNDS
)
>
/dev/null
...
...
This diff is collapsed.
Click to expand it.
prime.py
+
6
−
2
View file @
c795373a
#!/usr/bin/env python3
#!/usr/bin/env python
from
__future__
import
(
absolute_import
,
division
,
print_function
,
unicode_literals
)
def
is_prime
(
x
):
def
is_prime
(
x
):
from
math
import
sqrt
,
ceil
from
math
import
sqrt
,
ceil
if
sqrt
(
x
).
is_integer
():
if
sqrt
(
x
).
is_integer
():
return
False
return
False
for
i
in
range
(
2
,
ceil
(
sqrt
(
x
))):
for
i
in
range
(
2
,
int
(
ceil
(
sqrt
(
x
)))
)
:
if
x
%
i
==
0
:
if
x
%
i
==
0
:
return
False
return
False
return
True
return
True
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment