promptfoo icon indicating copy to clipboard operation
promptfoo copied to clipboard

Is there a way to see the time taken to run the entire test cases of a test suite from the UI?

Open albertlieyingadrian opened this issue 1 year ago • 1 comments

Or could it be added via hooks? e.g.

const { logger } = require('../helper/logger');

async function extensionHook(hookName, context) {
  if (hookName === 'beforeAll') {
    context.suite.startTime = new Date();
  } else if (hookName === 'afterAll') {
    const endTime = new Date();
    context.suite.totalTestTime = endTime - context.suite.startTime;

    logger.info(`Total tests: ${context.results.length}`);
    logger.info(`Total test time: ${context.suite.totalTestTime} ms`);
    // Perform any necessary teardown or reporting
  }
}

module.exports = extensionHook;

albertlieyingadrian avatar Sep 21 '24 04:09 albertlieyingadrian

I don't think we display this anywhere, but in theory we have the timing of every test case so could add it up. If you want an informal timer I usually just run with time promptfoo eval on the command line. Doing it with hooks is a clever idea

typpo avatar Sep 21 '24 17:09 typpo