Last active
January 18, 2020 00:48
-
-
Save EmmanuelOga/2f8983f89b29557c9beaa715be849110 to your computer and use it in GitHub Desktop.
Gotta find the best! Analyze result.json from https://tfb-status.techempower.com/
This file contains hidden or 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
| $ node analyze.js | |
| fortune | |
| java { fw: 'vertx-postgres', krps: 346 } | |
| java { fw: 'greenlightning', krps: 317 } | |
| java { fw: 'jooby-pgclient', krps: 308 } | |
| java { fw: 'proteus', krps: 266 } | |
| kotlin { fw: 'kooby', krps: 255 } | |
| -- | |
| plaintext | |
| java { fw: 'firenio-http-lite', krps: 7010 } | |
| java { fw: 'rapidoid-http-fast', krps: 6990 } | |
| java { fw: 'rapidoid', krps: 6975 } | |
| kotlin { fw: 'pronghorn', krps: 6918 } | |
| java { fw: 'firenio', krps: 5422 } | |
| -- | |
| json | |
| java { fw: 'firenio-http-lite', krps: 1700 } | |
| java { fw: 'firenio', krps: 1494 } | |
| kotlin { fw: 'pronghorn', krps: 1425 } | |
| java { fw: 'act', krps: 1306 } | |
| java { fw: 'proteus', krps: 1282 } | |
| -- | |
| java firenio-http-lite 8710 | |
| kotlin pronghorn 8343 | |
| java rapidoid 8221 | |
| java rapidoid-http-fast 8217 | |
| java firenio 6916 | |
| java proteus 6797 | |
| java officefloor-raw 6325 | |
| java greenlightning 5857 | |
| java jooby-mvc 5627 | |
| kotlin kooby 5490 | |
| java jooby 5466 | |
| java netty 5315 | |
| java act 5263 | |
| java light-4j 5159 | |
| java jooby-netty 5052 | |
| java vertx 4933 | |
| java undertow 4817 | |
| clojure reitit 4641 | |
| java voovan 4455 |
This file contains hidden or 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
| 'use strict'; | |
| const fs = require('fs'); | |
| const data = JSON.parse(fs.readFileSync('results.json')); | |
| const results = {}; | |
| const langs = {}; | |
| for (const obj of data.test_metadata) { | |
| langs[obj.name] = obj.language; | |
| } | |
| const areas = new Set([ | |
| 'json', | |
| 'plaintext', | |
| 'fortune', | |
| // 'db', | |
| // 'update', | |
| // 'query', | |
| // 'cached_query', | |
| ]); | |
| const blacklist = new Set([ | |
| 'c', | |
| 'c++', | |
| 'rust', | |
| 'scala', | |
| 'c#', | |
| 'go', | |
| ]); | |
| const allowed = new Set([ | |
| // 'f#', | |
| // 'vb', | |
| // 'd', | |
| // 'crystal', | |
| // 'elixir', | |
| // 'erlang', | |
| 'clojure', | |
| 'java', | |
| 'kotlin', | |
| // 'javascript', | |
| // 'typescript', | |
| // 'swift', | |
| // 'vala', | |
| // 'ur', | |
| // 'haskell', | |
| /* | |
| 'common lisp', | |
| 'dart', | |
| 'dylan', | |
| 'groovy', | |
| 'lua', | |
| 'nim', | |
| 'perl', | |
| 'php', | |
| 'python', | |
| 'racket', | |
| 'ruby', | |
| */ | |
| ]); | |
| for (const area of Object.keys(data.rawData)) { | |
| if (!areas.has(area)) continue; | |
| // key: framework. val: results. | |
| const frameworks = data.rawData[area]; | |
| const toSort = []; | |
| // Pick best result of each framework. | |
| for (const fw of Object.keys(frameworks)) { | |
| if (fw === 'wizzardo-http') continue; | |
| if (blacklist.has(langs[fw])) continue; | |
| if (allowed.length !== 0 && !(allowed.has(langs[fw]))) continue; | |
| const metrics = frameworks[fw]; | |
| if (!metrics || !metrics.map) continue; | |
| const rps = metrics | |
| .map( | |
| ({startTime, endTime, totalRequests}) => | |
| Math.round((totalRequests / (endTime - startTime)))) | |
| .sort((a, b) => b - a); | |
| if (rps[0] > 1000) { | |
| toSort.push({fw, rps: rps[0]}); | |
| } | |
| } | |
| const sorted = toSort.sort((a, b) => b.rps - a.rps); | |
| const max = toSort[0].rps; | |
| const min = toSort[toSort.length - 1].rps; | |
| results[area] = []; | |
| for (const item of sorted) { | |
| results[area].push(item); | |
| } | |
| } | |
| const scores = {}; | |
| for (const area of Object.keys(results)) { | |
| console.log(area); | |
| let count = 1; | |
| for (const item of results[area]) { | |
| if (count <= 5) { | |
| console.log(langs[item.fw], {fw: item.fw, krps: Math.round(item.rps / 1000)}); | |
| } | |
| scores[item.fw] = scores[item.fw] || 0; | |
| scores[item.fw] += Math.round(item.rps / 1000) | |
| count++; | |
| } | |
| console.log('--'); | |
| } | |
| const entries = Object.entries(scores).sort((a, b) => b[1] - a[1]); | |
| const max = entries[0][1]; | |
| const min = entries[entries.length - 1][1]; | |
| const threshold = min + (max - min) * 0.5; | |
| for (const [fw, score] of entries) { | |
| if (score > threshold) { | |
| console.log(langs[fw], fw, score); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment