Created
January 18, 2020 00:47
-
-
Save EmmanuelOga/0ae79683d12b0023404131494498627a to your computer and use it in GitHub Desktop.
Gotta find the best!
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