INNER CODE UNIT · TypeScript
getBinaryPath
hasura/graphql-bench · app/queries/src/executors/wrk2/index.ts:165
private async getBinaryPath() {
const defaultPath = await lookpath('wrk')
if (defaultPath) return defaultPath
const localWrkBinary = path.join(this.localBinaryFolder, 'wrk/wrk')
const localBinaryExists = await fs.pathExists(localWrkBinary)
if (localBinaryExists) return localWrkBinary
throw new Error(
'Could not find wrk binary either globally in $PATH or in local ./bin/wrk folder'
)
}
private async _runWrk2(metadata: RunWrk2Metadata, config: Wrk2BinaryArgs) {
const wrkPath = await this.getBinaryPath()
const start = new Date()
const wrk = execa(wrkPath, this._makeWrk2CmdArgs(config), {
env: {
// This is a bit hairy. We need the "graphql-bench.lua" script to be able to call require("json").
// By default, Lua files can "require" any other file in the same directory the program was run from. The "module context" is "./".