Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,15 @@ const beforeMiddleware = function (req, res, next) {
start = startMeasuring();
const previousSend = res.send
res.send = (data) => {
const value = endMeasuring(start)
const {cpu, memory} = endMeasuring(start)
res.send = previousSend
res.set('cpuMeasurement', JSON.stringify(value))
res.set('cpu', JSON.stringify(cpu))
res.set('memory', JSON.stringify(memory))
return res.send(data)
}
next();
};

// app.use(function (req, res, next) {
// res.on("finish", function () {
// endMeasuring(start);
// });
// next();
// });

app.use("/", beforeMiddleware, router);

const PORT = 3004;
Expand Down
2 changes: 1 addition & 1 deletion browser_client/public/main.js

Large diffs are not rendered by default.

250 changes: 250 additions & 0 deletions browser_client/public/main.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,250 @@
/*!
* accepts
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* body-parser
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* body-parser
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* bytes
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015 Jed Watson
* MIT Licensed
*/

/*!
* content-disposition
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* content-type
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* cookie
* Copyright(c) 2012-2014 Roman Shtylman
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* depd
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* destroy
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* ee-first
* Copyright(c) 2014 Jonathan Ong
* MIT Licensed
*/

/*!
* encodeurl
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* escape-html
* Copyright(c) 2012-2013 TJ Holowaychuk
* Copyright(c) 2015 Andreas Lubbe
* Copyright(c) 2015 Tiancheng "Timothy" Gu
* MIT Licensed
*/

/*!
* etag
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2013 Roman Shtylman
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* express
* Copyright(c) 2009-2013 TJ Holowaychuk
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* finalhandler
* Copyright(c) 2014-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* forwarded
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* fresh
* Copyright(c) 2012 TJ Holowaychuk
* Copyright(c) 2016-2017 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* http-errors
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* media-typer
* Copyright(c) 2014 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* merge-descriptors
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* methods
* Copyright(c) 2013-2014 TJ Holowaychuk
* Copyright(c) 2015-2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* mime-db
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* mime-types
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* negotiator
* Copyright(c) 2012 Federico Romero
* Copyright(c) 2012-2014 Isaac Z. Schlueter
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* on-finished
* Copyright(c) 2013 Jonathan Ong
* Copyright(c) 2014 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* parseurl
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* proxy-addr
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* range-parser
* Copyright(c) 2012-2014 TJ Holowaychuk
* Copyright(c) 2015-2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* raw-body
* Copyright(c) 2013-2014 Jonathan Ong
* Copyright(c) 2014-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* send
* Copyright(c) 2012 TJ Holowaychuk
* Copyright(c) 2014-2022 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* serve-static
* Copyright(c) 2010 Sencha Inc.
* Copyright(c) 2011 TJ Holowaychuk
* Copyright(c) 2014-2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* statuses
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* toidentifier
* Copyright(c) 2016 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* type-is
* Copyright(c) 2014 Jonathan Ong
* Copyright(c) 2014-2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* unpipe
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/

/*!
* vary
* Copyright(c) 2014-2017 Douglas Christopher Wilson
* MIT Licensed
*/

/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
2 changes: 1 addition & 1 deletion browser_client/public/main.js.map

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions browser_client/src/runAllTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import { runTestCase2 } from "./testCases/testCase2.js";
import { runTestCase3 } from "./testCases/testCase3.js";
import { runTestCase4 } from "./testCases/testCase4.js";
import { runTestCase5 } from "./testCases/testCase5.js";
import { runTestCase6 } from "./testCases/testCase6.js";

export async function runAllTests() {
//await runTestCase1();
// await runTestCase2()
await runTestCase3()
//await runTestCase4()
// await runTestCase5();
//await runTestCase3()
await runTestCase4()
// await runTestCase5();
//await runTestCase6();
}
10 changes: 5 additions & 5 deletions browser_client/src/testCases/testCase3.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const ids = [
"5c353b4c-70e3-414b-867b-e62d3e6109a1",
"2a2886c9-dcbe-4faf-a962-69ef6179010c",
"09496e23-c3f2-4250-ab26-3e62c8415023",
"5ea1f1fe-9fea-428e-a055-b2dfbe62c402",
"11953928-15b0-4abf-a1b7-f513565495cb",
"9cda1481-3239-4b70-b466-954eaadbe40c",
"d597fc1a-b56e-41d1-9189-cbfb6b476efa",
"1434e829-640e-416d-be0c-ca883317141e"
// "5ea1f1fe-9fea-428e-a055-b2dfbe62c402",
// "11953928-15b0-4abf-a1b7-f513565495cb",
// "9cda1481-3239-4b70-b466-954eaadbe40c",
// "d597fc1a-b56e-41d1-9189-cbfb6b476efa",
// "1434e829-640e-416d-be0c-ca883317141e"
]

const graphqlOptions = (id) => ({
Expand Down
6 changes: 5 additions & 1 deletion browser_client/src/testCases/testCase4.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ const graphqlOptions = (id) => ({
query: `
query GetQuestion($id: ID!){
getQuestionById(id: $id) {
id
answers {
id
body
user_id
question_id
score
accepted
user {
id
display_name
Expand Down
62 changes: 62 additions & 0 deletions browser_client/src/testCases/testCase6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { runTest } from "../runTest.js"
import { getMeasurements } from "../utils.js"

// get 1000 questions, the same fields for rest and graphql

const restEndpoint = '/rest/questions'

const graphqlEndpoint = '/graphql'

const graphqlOptions = (id) => ({
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
query GetQuestion($id: ID!){
getQuestionById(id: $id) {
id
owner_id
view_count
score
title
is_answered
answer_count
last_activity_date
creation_date
last_edit_date
content_license
link
body
answers {
id
body
user_id
question_id
score
accepted
}
}
}
`,
variables: {id}
}),
})


async function fetchGraphQL() {
const responses = await Promise.all([...Array(50).keys()].map(_ => fetch(graphqlEndpoint, graphqlOptions("11953928-15b0-4abf-a1b7-f513565495cb"))))
return getMeasurements(responses)
}

async function fetchRest() {
const responses = await Promise.all([...Array(50).keys()].map(_ => fetch(`${restEndpoint}/11953928-15b0-4abf-a1b7-f513565495cb`)))
return getMeasurements(responses)
}


export async function runTestCase6() {
await runTest('testCase6Rest', fetchRest)
await runTest('testCase6GraphQL', fetchGraphQL)
}
Loading