Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timers #58

Open
ff6347 opened this issue Jul 18, 2016 · 0 comments
Open

Timers #58

ff6347 opened this issue Jul 18, 2016 · 0 comments
Assignees
Labels
plugin idea for a plugin / relates to a plugin
Milestone

Comments

@ff6347
Copy link
Member

ff6347 commented Jul 18, 2016

As requested in #50
A function to create several Timers

function Timer() {
  var started = null;
  var stopped = null;
  this.start = function() {
    started = new Date();
  };
  this.stop = function() {
    stopped = new Date();
    var timetaken = (stopped.getTime() - started.getTime()) / 1000;
    return timetaken;
  };
}

The usage would be like this:

// the delay function is just for testing
function delay(prmSec) {
  prmSec *= 1000;
  var eDate = null;
  var eMsec = 0;
  var sDate = new Date();
  var sMsec = sDate.getTime();
  do {
    eDate = new Date();
    eMsec = eDate.getTime();
  } while ((eMsec - sMsec) < prmSec);
}
// usage
var duration = new Timer(); 
duration.start();
delay(1.456);
$.writeln(duration.stop());
@ff6347 ff6347 added the feature label Jul 18, 2016
@ff6347 ff6347 added this to the Features milestone Jul 18, 2016
@ff6347 ff6347 self-assigned this Nov 11, 2016
@trych trych added plugin idea for a plugin / relates to a plugin and removed feature labels Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin idea for a plugin / relates to a plugin
Projects
None yet
Development

No branches or pull requests

2 participants