Joséph Flames Joséph Flames - 1 year ago 88
Javascript Question

function to calculate function fps

Ok so I believe I could best describe the issue through code so here goes

var clicks = 0;

//function to calculate
function clicking(){
clicks += 1;

//function to calculate fps where fn is the name of the function
function FPS(fn){
//do stuff

Okay so to clarify I dont want to add a variable to the actual function
I would like to be able to call something like
and have the function return a value for example

var fps = FPS(clicking);

then i could display the returned number as such
element.innerHTML = fps

I know with the current code it seems silly but this is just example coding not what I am actually using

Answer Source

This is not very actual since also uses time.

function FPS(fn) {
  var startTime =;
  var endTime =;

  return endTime - startTime;

function longClick() {
  var abc = 0;
  for (var i = 0; i < 100000000; i++) {

var fps = FPS(longClick);
console.log((fps / 1000) + ' seconds');

FPS usually refers to Frames Per Second which is the frequency of refreshing screen image.

Pick a more comprehensive name, with keywords like Elapsed, for teammates.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download