FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaArithmetic/src/datastructure/queue/test/Main.java at master · sqlcyi2008/JavaArithmetic · GitHub
sqlcyi2008
JavaArithmetic
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaArithmetic
/
src
/
datastructure
/
queue
/
test
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
35 lines (24 loc) · 1.02 KB
Breadcrumbs
JavaArithmetic
/
src
/
datastructure
/
queue
/
test
/
Main.java
Copy path
File metadata and controls
35 lines (24 loc) · 1.02 KB
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
package
datastructure
.
queue
.
test
;
import
java
.
util
.
Random
;
public
class
Main
{
// 测试使用q运行opCount个enqueueu和dequeue操作所需要的时间,单位:秒
private
static
double
testQueue
(
Queue
<
Integer
>
q
,
int
opCount
){
long
startTime
=
System
.
nanoTime
();
Random
random
=
new
Random
();
for
(
int
i
=
0
;
i
<
opCount
;
i
++)
q
.
enqueue
(
random
.
nextInt
(
Integer
.
MAX_VALUE
));
for
(
int
i
=
0
;
i
<
opCount
;
i
++)
q
.
dequeue
();
long
endTime
=
System
.
nanoTime
();
return
(
endTime
-
startTime
) /
1000000000.0
;
}
public
static
void
main
(
String
[]
args
) {
int
opCount
=
100000
;
ArrayQueue
<
Integer
>
arrayQueue
=
new
ArrayQueue
<>();
double
time1
=
testQueue
(
arrayQueue
,
opCount
);
System
.
out
.
println
(
"ArrayQueue, time: "
+
time1
+
" s"
);
LoopQueue
<
Integer
>
loopQueue
=
new
LoopQueue
<>();
double
time2
=
testQueue
(
loopQueue
,
opCount
);
System
.
out
.
println
(
"LoopQueue, time: "
+
time2
+
" s"
);
}
}
Back
|
FazBrowse Home
|
New Git URL