FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
graphql-java/src/jmh/java/benchmark/AsyncBenchmark.java at master · graphql-java/graphql-java · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
graphql-java
/
graphql-java
Public
Notifications
You must be signed in to change notification settings
Fork
1.1k
Star
6.2k
Code
Issues
22
Pull requests
17
Discussions
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
graphql-java
/
src
/
jmh
/
java
/
benchmark
/
AsyncBenchmark.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
68 lines (55 loc) · 2.01 KB
Breadcrumbs
graphql-java
/
src
/
jmh
/
java
/
benchmark
/
AsyncBenchmark.java
Copy path
File metadata and controls
68 lines (55 loc) · 2.01 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package
benchmark
;
import
graphql
.
execution
.
Async
;
import
org
.
openjdk
.
jmh
.
annotations
.
Benchmark
;
import
org
.
openjdk
.
jmh
.
annotations
.
BenchmarkMode
;
import
org
.
openjdk
.
jmh
.
annotations
.
Fork
;
import
org
.
openjdk
.
jmh
.
annotations
.
Level
;
import
org
.
openjdk
.
jmh
.
annotations
.
Measurement
;
import
org
.
openjdk
.
jmh
.
annotations
.
Mode
;
import
org
.
openjdk
.
jmh
.
annotations
.
Param
;
import
org
.
openjdk
.
jmh
.
annotations
.
Scope
;
import
org
.
openjdk
.
jmh
.
annotations
.
Setup
;
import
org
.
openjdk
.
jmh
.
annotations
.
State
;
import
org
.
openjdk
.
jmh
.
annotations
.
Warmup
;
import
org
.
openjdk
.
jmh
.
runner
.
Runner
;
import
org
.
openjdk
.
jmh
.
runner
.
options
.
Options
;
import
org
.
openjdk
.
jmh
.
runner
.
options
.
OptionsBuilder
;
import
java
.
util
.
ArrayList
;
import
java
.
util
.
List
;
import
java
.
util
.
concurrent
.
CompletableFuture
;
import
java
.
util
.
concurrent
.
ExecutionException
;
import
java
.
util
.
concurrent
.
TimeUnit
;
@
State
(
Scope
.
Benchmark
)
@
BenchmarkMode
(
Mode
.
Throughput
)
@
Warmup
(
iterations
=
2
)
@
Measurement
(
iterations
=
2
,
timeUnit
=
TimeUnit
.
NANOSECONDS
)
@
Fork
(
2
)
public
class
AsyncBenchmark
{
@
Param
({
"1"
,
"5"
,
"20"
})
public
int
numberOfFieldCFs
;
List
<
CompletableFuture
<
Object
>>
futures
;
@
Setup
(
Level
.
Trial
)
public
void
setUp
()
throws
ExecutionException
,
InterruptedException
{
futures
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
numberOfFieldCFs
;
i
++) {
futures
.
add
(
mkFuture
(
i
));
}
}
private
CompletableFuture
<
Object
>
mkFuture
(
int
i
) {
return
CompletableFuture
.
completedFuture
(
i
);
}
@
Benchmark
@
Warmup
(
iterations
=
2
,
batchSize
=
100
)
@
Measurement
(
iterations
=
2
,
batchSize
=
100
)
public
List
<
Object
>
benchmarkAsync
() {
Async
.
CombinedBuilder
<
Object
>
builder
=
Async
.
ofExpectedSize
(
futures
.
size
());
futures
.
forEach
(
builder
::
add
);
return
builder
.
await
().
join
();
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Options
opt
=
new
OptionsBuilder
()
.
include
(
"benchmark.AsyncBenchmark"
)
.
build
();
new
Runner
(
opt
).
run
();
}
}
Back
|
FazBrowse Home
|
New Git URL