-
-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32bb7ac
commit c86d2aa
Showing
6 changed files
with
105 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,45 @@ | ||
package caliban | ||
|
||
import caliban.parsing.Parser | ||
import cats.effect.IO | ||
import io.circe.Json | ||
import org.openjdk.jmh.annotations._ | ||
import sangria.execution._ | ||
import sangria.marshalling.circe._ | ||
import org.openjdk.jmh.infra.Blackhole | ||
import sangria.parser.QueryParser | ||
|
||
import java.util.concurrent.TimeUnit | ||
import scala.concurrent.duration._ | ||
import scala.concurrent.{ Await, ExecutionContextExecutor, Future } | ||
import scala.concurrent.ExecutionContextExecutor | ||
|
||
@State(Scope.Thread) | ||
@BenchmarkMode(Array(Mode.Throughput)) | ||
@OutputTimeUnit(TimeUnit.SECONDS) | ||
@Warmup(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) | ||
@Measurement(iterations = 5, time = 3, timeUnit = TimeUnit.SECONDS) | ||
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) | ||
@Fork(1) | ||
class ParserBenchmark { | ||
import ComplexQueryBenchmark._ | ||
|
||
implicit val executionContext: ExecutionContextExecutor = scala.concurrent.ExecutionContext.global | ||
|
||
@Benchmark | ||
def runCaliban(): Unit = { | ||
val io = Parser.parseQuery(fullIntrospectionQuery) | ||
Caliban.run(io) | ||
def runCaliban(bh: Blackhole): Unit = { | ||
bh.consume(Parser.parseQueryEither(fullIntrospectionQuery).fold(throw _, identity)) | ||
() | ||
} | ||
|
||
@Benchmark | ||
def runSangria(): Unit = { | ||
val future = Future.fromTry(QueryParser.parse(fullIntrospectionQuery)) | ||
Await.result(future, 1.minute) | ||
def runSangria(bh: Blackhole): Unit = { | ||
bh.consume(QueryParser.parse(fullIntrospectionQuery).fold(throw _, identity)) | ||
() | ||
} | ||
|
||
@Benchmark | ||
def runGrackle(): Unit = { | ||
Grackle.compiler.compile(fullIntrospectionQuery) | ||
def runGrackle(bh: Blackhole): Unit = { | ||
bh.consume(Grackle.compiler.compile(fullIntrospectionQuery)) | ||
() | ||
} | ||
|
||
@Benchmark | ||
def runGql(): Unit = { | ||
gql.parser.parseQuery(fullIntrospectionQuery) | ||
def runGql(bh: Blackhole): Unit = { | ||
bh.consume(gql.parser.parseQuery(fullIntrospectionQuery)) | ||
() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters