FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java/src/test/java/com/examplehub/maths/OddCheckTest.java at master · alimogh/Java · GitHub
alimogh
/
Java
Public
forked from
examplehub/Java
Notifications
You must be signed in to change notification settings
Fork
1
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
examplehub
/
maths
/
OddCheckTest.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (32 loc) · 909 Bytes
Breadcrumbs
Java
/
src
/
test
/
java
/
com
/
examplehub
/
maths
/
OddCheckTest.java
Copy path
File metadata and controls
41 lines (32 loc) · 909 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
package
com
.
examplehub
.
maths
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.
assertTrue
;
import
com
.
examplehub
.
utils
.
RandomUtils
;
import
org
.
junit
.
jupiter
.
api
.
Test
;
class
OddCheckTest
{
@
Test
void
isOdd
() {
for
(
int
i
= -
99
;
i
<=
99
;
i
+=
2
) {
assertTrue
(
OddCheck
.
isOdd
(
i
));
}
}
@
Test
void
isOddFaster
() {
for
(
int
i
= -
99
;
i
<=
99
;
i
+=
2
) {
assertTrue
(
OddCheck
.
isOddFaster
(
i
));
}
}
void
testSpeed
() {
int
[]
ints
=
RandomUtils
.
randomInts
(-
1000
,
1000
,
Integer
.
MAX_VALUE
);
long
startTime
=
System
.
nanoTime
();
for
(
int
j
:
ints
) {
boolean
isOdd
=
OddCheck
.
isOdd
(
j
);
}
long
slowTime
=
System
.
nanoTime
() -
startTime
;
startTime
=
System
.
nanoTime
();
for
(
int
anInt
:
ints
) {
boolean
isOdd
=
OddCheck
.
isOddFaster
(
anInt
);
}
long
fasterTime
=
System
.
nanoTime
() -
startTime
;
assertTrue
(
fasterTime
<
slowTime
);
}
}
Back
|
FazBrowse Home
|
New Git URL