diff --git a/.gitignore b/.gitignore index cdab2281..eb929ceb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,6 @@ target obj __pycache__ .metals -.bloop \ No newline at end of file +.bloop +.idea +.bsp diff --git a/benchmarks.yaml b/benchmarks.yaml index fcdba4cb..938dc7f9 100644 --- a/benchmarks.yaml +++ b/benchmarks.yaml @@ -94,13 +94,13 @@ run: cmd: node args: ["index.js"] -- id: nim-graphql - name: nim-graphql - url: https://github.com/status-im/nim-graphql - lang: Nim - server: Chronos - run: - cmd: ./main +#- id: nim-graphql +# name: nim-graphql +# url: https://github.com/status-im/nim-graphql +# lang: Nim +# server: Chronos +# run: +# cmd: ./main - id: graphql-ruby name: graphql-ruby url: https://github.com/rmosolgo/graphql-ruby @@ -217,3 +217,16 @@ args: - start - ./main.graphql +- id: caliban + name: Caliban + url: https://ghostdogpr.github.io/caliban/ + lang: Scala + server: ZIO Http + run: + cmd: java + args: + [ + "-Xmx4G", + "-jar", + "./target/scala-3.4.1/caliban-assembly-0.1.0-SNAPSHOT.jar", + ] diff --git a/caliban/.scalafmt.conf b/caliban/.scalafmt.conf new file mode 100644 index 00000000..131e8c90 --- /dev/null +++ b/caliban/.scalafmt.conf @@ -0,0 +1,5 @@ +version = "3.7.14" +runner.dialect = "scala3" + +align.preset = more +maxColumn = 120 diff --git a/caliban/build.sbt b/caliban/build.sbt new file mode 100644 index 00000000..4172a92f --- /dev/null +++ b/caliban/build.sbt @@ -0,0 +1,14 @@ +name := "caliban" +scalaVersion := "3.4.1" + +assembly / mainClass := Some("Main") + +assembly / assemblyMergeStrategy := { + case PathList("META-INF", "MANIFEST.MF") => MergeStrategy.discard + case PathList("META-INF", "io.netty.versions.properties") => MergeStrategy.first + case x => MergeStrategy.first +} + +libraryDependencies ++= Seq( + "com.github.ghostdogpr" %% "caliban-quick" % "2.6.0" +) diff --git a/caliban/project/build.properties b/caliban/project/build.properties new file mode 100644 index 00000000..b19d4e1e --- /dev/null +++ b/caliban/project/build.properties @@ -0,0 +1 @@ +sbt.version = 1.9.7 diff --git a/caliban/project/plugins.sbt b/caliban/project/plugins.sbt new file mode 100644 index 00000000..c7632d57 --- /dev/null +++ b/caliban/project/plugins.sbt @@ -0,0 +1 @@ +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.4") diff --git a/caliban/src/main/scala/Main.scala b/caliban/src/main/scala/Main.scala new file mode 100644 index 00000000..673efeaf --- /dev/null +++ b/caliban/src/main/scala/Main.scala @@ -0,0 +1,18 @@ +import caliban.* +import caliban.quick.* +import caliban.schema.Schema +import zio.* + +case class Query(hello: String) derives Schema.SemiAuto + +object Main extends ZIOAppDefault { + override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] = + ZLayer.make[Any]( + Runtime.setExecutor(Executor.makeDefault(false)), + ZLayer.scoped(ZIO.withRuntimeFlagsScoped(RuntimeFlags.disable(RuntimeFlag.FiberRoots))) + ) + + private val api = graphQL(RootResolver(Query("world"))) + + def run = ZIO.yieldNow *> api.runServer(8000, "/graphql") +} diff --git a/run.cr b/run.cr index 3b38d912..3656906f 100755 --- a/run.cr +++ b/run.cr @@ -27,8 +27,8 @@ benchmarks.map do |b| run("bundle", ["install", "--quiet"], dir, true) if File.exists? dir.join("Gemfile") run("mix", ["deps.get", "--only", "prod"], dir, true) if File.exists? dir.join("mix.exs") run("mix", ["compile"], dir, true) if File.exists? dir.join("mix.exs") - run("nimble", ["--silent", "-y", "install"], dir, true) if File.exists? dir.join("main.nimble") - run("nimble", ["--silent", "-y", "build", "-d:release", "-d:chronicles_log_level=WARN"], dir, true) if File.exists? dir.join("main.nimble") + # run("nimble", ["--silent", "-y", "install"], dir, true) if File.exists? dir.join("main.nimble") + # run("nimble", ["--silent", "-y", "build", "-d:release", "-d:chronicles_log_level=WARN"], dir, true) if File.exists? dir.join("main.nimble") run("dub", ["--quiet", "build", "-b=release"], dir, true) if File.exists? dir.join("dub.json") ch.send(nil) rescue ex @@ -56,17 +56,20 @@ benchmarks.each_with_index do |b, i| sleep 1 end - res = (0...1).map do |_| + res = (0...3).map do |_| output = IO::Memory.new run("bombardier", ["-c#{System.cpu_count * 50}", "-d5s", "-mPOST", %(-b{"query":"{ hello }"}), "-HContent-Type: application/json", "-ojson", "-pr", "http://localhost:8000/graphql"], wait: true, output: output) + sleep 1 output.to_s end.last p.terminate r = p.wait if r.exit_code != 0 - puts "command failed with exit code #{r.exit_code}" - exit 1 + if r.exit_code != 143 + puts "command failed with exit code #{r.exit_code}" + exit 1 + end end benchmarks[i].result = JSON.parse(res.split('\n').last)["result"]