Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6890315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:15:58+00:00 2026-05-27T06:15:58+00:00

I am writing some debug code in a real-time javascript app. In the update

  • 0

I am writing some debug code in a real-time javascript app. In the update loop, I want to:

  1. get current time in milliseconds
  2. compare to last frame’s time and print out framerate
  3. set last frame’s time to current time from the variable above

All straightforward, except that since it’s in such a performance-critical piece of code, I’m trying not to call

var d=new Date();

every frame before I call

thisFrameTime = d.getTime();

Is this possible? Is there something along the lines of:

d.now

which updates the time in the existing date object?

My thinking is that I want to stay away from memory allocation / gc while in debug mode so it impacts framerate less – but maybe that’s just not how it’s done in javascript? (My background is more C/C++, so maybe this is not the right way of thinking for JS?)

I have searched Google and Stack Overflow, and can’t seem to find an answer, which makes me think it’s not possible. If that’s the case, confirmation would be helpful.

Would love any thoughts – what’s the most performant way to get this done?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:15:59+00:00Added an answer on May 27, 2026 at 6:15 am

    There is a Date.now() function.

    var time = Date.now()
    

    The problem is that it is a part of EcmaScript 5 so older browser (IE 6-8) don’t support it. As written on the MDM (link above) you can solve this issue by including this into your code:

    if (!Date.now) {  
      Date.now = function() {  
        return +(new Date);  
      };  
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I'm writing some ruby code and I want to use the standard Date
I'm writing some semi-portable code and want to be able to detect when I'm
I'm writing an application wherein I have some debug code that I do not
I am writing some tests for Javascript code and I need to dump some
For some debug code I'm writing Trace code I'm trying to output the name
I'm writing some lines of code to get acquainted with the basics of Quartz
Writing some test scripts in IronPython, I want to verify whether a window is
While writing some C code, I decided to compile it to assembly and read
I am writing some code to determine whether a network domain is registered. For
So I was writing some code today that basically looks like this: string returnString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.