Coder Social home page Coder Social logo

Comments (5)

ErickWendel avatar ErickWendel commented on June 5, 2024 1

thanks a lot!! I also have it in English on that channel o/

from poku.

1NxT avatar 1NxT commented on June 5, 2024

Something like that?
image

from poku.

wellwelwel avatar wellwelwel commented on June 5, 2024

Thanks, @1NxT 🚀

I think (0.000000ms) should be good.

The idea would be:

  • If the user use test, it will show the execution time for each test performed
  • At the end of each file (using test method or not), it will show the total for each file
  • On exit, it will show the final total of the tests

It's important to note that Poku's assert simplify the test process by turning test, describe and it in a simple assert(true, "Describing it"), so it's not necessary to include an execution time for each assertion 🙋🏻‍♂️

For example:

A) Shows only the file and total execution time:

import { assert } from 'poku';

assert.strictEqual(1, 1, 'Describing it');

B) Shows both the test, file and total execution times:

import { test, assert } from 'poku';

// This should show the execution time
test(() => {
  // This is just an assertion
  assert.strictEqual(1, 1, 'Describing it too');
});

Feel free to discuss it 🤝

from poku.

1NxT avatar 1NxT commented on June 5, 2024

I was reading the code trying console log the time, I used the file parseAsssetion.ts to try to measure the time of each assert.

  var startTime = performance.now();
  const isPoku =
    typeof process.env?.FILE === 'string' && process.env?.FILE.length > 0;
  const FILE = process.env.FILE;

  try {
    ...

    if (typeof options.message === 'string') {
      var endTime = performance.now();
      const message = isPoku
        ? `${format.bold(format.success(`✔ ${options.message}`))} ${format.dim(format.success(`› ${FILE}`))} ${format.dim(`(${(endTime - startTime).toFixed(6)}ms)`)}`
        : format.bold(format.success(`✔ ${options.message}`)) + ` ${format.dim(`(${(endTime - startTime).toFixed(6)}ms)`)}`;

      console.log(message);
    }

But I don't know if it's a good approach.

from poku.

wellwelwel avatar wellwelwel commented on June 5, 2024

I was reading the code trying console log the time

@1NxT, I believe that perf_hooks would be a good approach (I didn't get to try it):

import { performance } from 'node:perf_hooks';

const start = performance.now();
const end = performance.now();
const total = (end - start).toFixed(6);

We could begin with the total time per file:

Start:

if (!(await beforeEach(fileRelative, configs))) return false;

End:

if (!(await afterEach(fileRelative, configs))) return false;


Note to self

It would be interesting not to affect the execution time of the test itself with the Poku process, but we could think about this later.

from poku.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.