Nate пре 3 година
родитељ
комит
fb140500c6

+ 0 - 46
frameworks/Crystal/orion/README.md

@@ -1,46 +0,0 @@
-This is the [Orion](https://github.com/obsidian/orion) test of the Framework Benchmarks.
-Crystal is a new language that closely resembles Ruby with a goal of removing typed variables and parameters (instead inferencing), whilst maintaining top speed through bindings into C.
-
-Orion is a powerful, simple, rails-esque routing library for HTTP::Server
-
-
-# orion Benchmarking Test
-
-### Test Type Implementation Source Code
-
-* [JSON](orion.cr)
-* [PLAINTEXT](orion.cr)
-* [DB](orion.cr)
-* [QUERY](orion.cr)
-* [CACHED QUERY](orion.cr)
-* [UPDATE](orion.cr)
-* [FORTUNES](orion.cr)
-
-## Test URLs
-### JSON
-
-http://localhost:8080/json
-
-### PLAINTEXT
-
-http://localhost:8080/plaintext
-
-### DB
-
-http://localhost:8080/db
-
-### QUERY
-
-http://localhost:8080/query?queries=
-
-### CACHED QUERY
-
-http://localhost:8080/cached_query?queries=
-
-### UPDATE
-
-http://localhost:8080/update?queries=
-
-### FORTUNES
-
-http://localhost:8080/fortunes

+ 0 - 30
frameworks/Crystal/orion/benchmark_config.json

@@ -1,30 +0,0 @@
-{
-  "framework": "orion",
-  "tests": [
-    {
-      "default": {
-        "json_url": "/json",
-        "plaintext_url": "/plaintext",
-        "db_url": "/db",
-        "query_url": "/queries?queries=",
-        "fortune_url": "/fortunes",
-        "update_url": "/updates?queries=",
-        "port": 8080,
-        "approach": "Realistic",
-        "classification": "Micro",
-        "database": "postgres",
-        "framework": "orion",
-        "language": "Crystal",
-        "flavor": "None",
-        "orm": "Micro",
-        "platform": "None",
-        "webserver": "None",
-        "os": "Linux",
-        "database_os": "Linux",
-        "display_name": "orion",
-        "notes": "",
-        "versus": "None"
-      }
-    }
-  ]
-}

+ 0 - 19
frameworks/Crystal/orion/config.toml

@@ -1,19 +0,0 @@
-[framework]
-name = "orion"
-
-[main]
-urls.plaintext = "/plaintext"
-urls.json = "/json"
-urls.db = "/db"
-urls.query = "/queries?queries="
-urls.update = "/updates?queries="
-urls.fortune = "/fortunes"
-approach = "Realistic"
-classification = "Micro"
-database = "postgres"
-database_os = "Linux"
-os = "Linux"
-orm = "Micro"
-platform = "None"
-webserver = "None"
-versus = "None"

+ 0 - 116
frameworks/Crystal/orion/orion.cr

@@ -1,116 +0,0 @@
-require "orion"
-require "json"
-require "ecr/macros"
-require "pg"
-
-APPDB      = DB.open(ENV["DATABASE_URL"])
-ID_MAXIMUM = 10_000
-
-private def random_world
-  id = rand(1..ID_MAXIMUM)
-  id, random_number = APPDB.query_one("SELECT id, randomNumber FROM world WHERE id = $1", id, as: {Int32, Int32})
-  {id: id, randomNumber: random_number}
-end
-
-private def set_world(world)
-  APPDB.exec("UPDATE world SET randomNumber = $1 WHERE id = $2", world[:randomNumber], world[:id])
-  world
-end
-
-private def fortunes
-  data = Array(NamedTuple(id: Int32, message: String)).new
-
-  APPDB.query_each("SELECT id, message FROM Fortune") do |rs|
-    data.push({id: rs.read(Int32), message: rs.read(String)})
-  end
-
-  data
-end
-
-private def sanitized_query_count(request)
-  queries = request.query_params["queries"]? || "1"
-  queries = queries.to_i? || 1
-  queries.clamp(1..500)
-end
-
-router Bench do
-  #
-  # Basic Tests
-  #
-
-  # Test 1: JSON Serialization
-  get "/json" do |context|
-    context.response.headers["Server"] = "Orion"
-    context.response.headers["Date"] = HTTP.format_time(Time.utc)
-    context.response.headers["content-type"] = "application/json"
-
-    context.response.puts({message: "Hello, World!"}.to_json)
-  end
-
-  # Test 2: Plaintext
-  get "/plaintext" do |context|
-    context.response.headers["Server"] = "Orion"
-    context.response.headers["Date"] = HTTP.format_time(Time.utc)
-    context.response.headers["content-type"] = "text/plain"
-
-    context.response.print "Hello, World!"
-  end
-
-  #
-  # Postgres DatabaseTests
-  #
-
-  # Postgres Test 3: Single database query
-  get "/db" do |context|
-    context.response.headers["Server"] = "Orion"
-    context.response.headers["Date"] = HTTP.format_time(Time.utc)
-    context.response.headers["content-type"] = "application/json"
-
-    context.response.puts random_world.to_json
-  end
-
-  # Postgres Test 4: Multiple database query
-  get "/queries" do |context|
-    results = (1..sanitized_query_count(context.request)).map do
-      random_world
-    end
-    context.response.headers["Server"] = "Orion"
-    context.response.headers["Date"] = HTTP.format_time(Time.utc)
-    context.response.headers["content-type"] = "application/json"
-
-    context.response.puts results.to_json
-  end
-
-  # Postgres Test 5: HMTL template render
-  get "/fortunes" do |context|
-    data = fortunes
-    additional_fortune = {
-      id:      0,
-      message: "Additional fortune added at request time.",
-    }
-    data.push(additional_fortune)
-    data.sort_by! { |fortune| fortune[:message] }
-    io = IO::Memory.new
-    ECR.embed "views/fortunes.ecr", io
-
-    context.response.headers["Server"] = "Orion"
-    context.response.headers["Date"] = HTTP.format_time(Time.utc)
-    context.response.headers["content-type"] = "text/html; charset=UTF-8"
-
-    context.response.puts io.to_s
-  end
-
-  # Postgres Test 6: Data updates
-  get "/updates" do |context|
-    updated = (1..sanitized_query_count(context.request)).map do
-      set_world({id: random_world[:id], randomNumber: rand(1..ID_MAXIMUM)})
-    end
-    context.response.headers["Server"] = "Orion"
-    context.response.headers["Date"] = HTTP.format_time(Time.utc)
-    context.response.headers["content-type"] = "application/json"
-
-    context.response.puts updated.to_json
-  end
-end
-
-Bench.listen(host: "0.0.0.0", port: 8080, reuse_port: true)

+ 0 - 16
frameworks/Crystal/orion/orion.dockerfile

@@ -1,16 +0,0 @@
-FROM crystallang/crystal:0.34.0
-
-WORKDIR /orion
-COPY views views
-COPY run.sh run.sh
-COPY orion.cr orion.cr
-COPY shard.yml shard.yml
-
-ENV DATABASE_URL postgres://benchmarkdbuser:benchmarkdbpass@tfb-database:5432/hello_world?initial_pool_size=56&max_idle_pool_size=56
-
-RUN shards install
-RUN crystal build  --release --no-debug orion.cr
-
-EXPOSE 8080
-
-CMD bash run.sh

+ 0 - 7
frameworks/Crystal/orion/run.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-for i in $(seq 1 $(nproc --all)); do
-  ./orion &
-done
-
-wait

+ 0 - 17
frameworks/Crystal/orion/shard.yml

@@ -1,17 +0,0 @@
-name: orion
-version: 0.1.0
-
-authors:
-  - Carlos Donderis <[email protected]>
-
-dependencies:
-  orion:
-    github: obsidian/orion
-  pg:
-    github: will/crystal-pg
-
-targets:
-  orion:
-    main: orion.cr
-
-crystal: 0.34.0

+ 0 - 20
frameworks/Crystal/orion/views/fortunes.ecr

@@ -1,20 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-	<title>Fortunes</title>
-</head>
-<body>
-	<table>
-		<tr>
-		<th>id</th>
-		<th>message</th>
-		</tr>
-		<% data.each do |fortune| %>
-			<tr>
-			<td><%= fortune[:id] %></td>
-			<td><%= HTML.escape(fortune[:message]) %></td>
-			</tr>
-		<% end %>
-	</table>
-</body>
-</html>