FAQ Database Discussion Community


Where does a browser event's timeStamp come from in Javascript?

javascript,event-handling,timing
Event objects passed to event handler callbacks contain an event.timeStamp of when the event occurred, but where is the timestamp produced? Is it something that bubbles up from the underlying OS, or is it generated by the browser? I'm interested in gauging the reliability of the timestamp and recognise that...

how to stop timer with another function javascript

javascript,html,timer,timing
So I have this code function timer() { setTimeout(function(){alert("Out of time")}, 3000); //Alerts "Out of time" after 3000 milliseconds } function resetTime() { timer(); //this is not right, i thought it would override the first function but it just adds another timer as well which is not what I want...

Forcing a CSS animation to complete

css,animation,css-animations,timing
For an artist's web site, where the pictures completely fill the browser window, I want to show a strip of thumbnails which will disappear to leave only the thumbnail for the current image in the corner. When you roll the mouse over this thumbnail, the strip of thumbnails should reappear...

How to call a function at different intervals in GSAP or Javascript?

javascript,timing,tweenlite,gsap
I have a very basic slideshow as follows: HTML <div id="slideshow"> <img class="slide" src="img/slideshow-1.png" > <img class="slide" src="img/slideshow-2.png" > <img class="slide" src="img/slideshow-3.png" > </div> JS $(function(){ var $slides = $(".slide"); //slides var currentSlide = 0; //keep track on the current slide var stayTime = 3; //time the slide stays var...

How does javascript setInterval and setTimeout 'threads' works?

javascript,jquery,settimeout,setinterval,timing
Let's consider such html: <div class="my-class"></div> and js (using jQuery): var interval = 10; setInterval(function(){ //I toggle .my-class 'extra-class' every 10ms $(".my-class").toggleClass("extra-class"); }, interval); //then outside interval I'm doing some action on the same item as interval does $(".my-class").each(function(){ var t = $(this).addClass("extra-class"); //I'm sure I've added extra-class //but now...

How to time how long it takes to insert and sort separatley in a TreeMap [duplicate]

java,performance,sorting,comparator,timing
This question already has an answer here: How do I time a method's execution in Java? 29 answers I would like to time how long the program takes to insert in the tree to measure the efficiency of a TreeMap's inserting. I also want to measure how long it...

Java, sometimes I read a negative difference between two System.currentTimeMillis()

java,timing
On a jogl sample of mine, I am having some performances issue. I would like to profile it on the cpu side and I am using System.currentTimeMillis(). This is the main loop of my application: @Override public void display(GLAutoDrawable glad) { frameTimer.stop(); frameDelta = frameTimer.getTime(); // just an estimate totalTime...

timing a function call as if-statement condition in cpp

c++,if-statement,timing,chrono
I have a function and sometimes it gets called as a condition in if-statements, and I am interested to time exactly these calls. I wonder if there is any way to do something like this for timing it in cpp: using watch = std::chrono::high_resolution_clock; std::chrono::nanoseconds time(0); if ( auto start...

jQuery - call a function from another function after 3 second delay

jquery,function,animation,delay,timing
I'm trying to run a quick animation on scroll, however I can't get the desired effect to repeat when necessary. I have a little cartoon guy appear on my site when the document is ready: Var SpriteVis; jQuery(document).ready(function tele_in($) { // function to make sprite appear. $("#sprite").animate({bottom: '0px'}, 400, 'linear',...

Power and timing reports of two different vhdl designs

performance,report,vhdl,timing,area
Let's suppose I have two circuits (described in vhdl), the first one performs the following algorithm in loop(pseudo code): C<=A+B; D<=C+F; RES <= D; I represent this algorithm applying the Finite State Machine(FSM) logic. Thus: State1:C<=A+B; out_ready<='0';--the result is not ready yet nextstate<=State2; State2:D<=C+F; nextstate<=S_out; S_out: RES<=D; out_ready<='1';--the result is...

How to loop this simple jQuery animation 3 times then stop?

jquery,animation,timing
I'm trying to get the word "READY" to flash 3 times and then disappear like they do in old school video games. I'm using jQuery to change the css from display: block; to display: none; but I can't get it to work and I'm also new to animating with jQuery...

timing experiment on bst in haskell

haskell,binary-search-tree,timing
Hi i am trying to learn haskell and compare its performance to other languages when i run the following code.. module BST ( Tree, singletonTree, insert, member ) where import System.IO import System.IO.Error hiding (try) import Control.Exception import Data.Char import System.CPUTime -- -- Take the string and convert it to...

Fair timing of two equivalent functions with -O3

c++,optimization,timing
A coworker sent me some interesting code the calculates the index of the LSB of an integer: unsigned int v; // the input number int r; // result goes here static const int MultiplyDeBruijnBitPosition[32] = { 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17,...

Advantage of using Boomerang library vs Resource Timing API

javascript,angularjs,node.js,timing,boomerang
I'm working on a project that is using Node.js on a back-end, and Angular.js as a front-end and I need to capture page load statistics for different resources of the app across different browsers. I was able to gather basic statistics by using Resource Timing API and storing the resulting...

Best way to timing events in Qt

c++,qt,timing,qtimer
I'm writing a software in Qt/c++ that communicate through serial with arduino and other electronic devices. I need to start a sequence of events that call different slot with different timing like this: Start Motor 1 For 20 seconds After 10 seconds Start Motor 2 Stop Motor 1 Change Motor...

Matlab timeit equivalent in Python for scripts

python,matlab,timing
In Matlab there is "timeit(F), which measures the typical time (in seconds) required to run the function specified by the function handle F that takes no input argument." This method returns the median of (I think 13) runs of the function. Having looked at the methods time and timeit in...

get cpu time of an external process and it children while it still running on OS X

c,linux,osx,timing,cpu-time
On linux I can use /proc as stated in Calculating CPU usage of a process in Linux to get the cpu time of a process and it children. How would I do this on OS X?...

Timing of document.write injected javascripts

javascript,asynchronous,google-analytics,timing
It looks like this code is causing a timing problem. At what point after the execution of this script will ga.js run? How can we be sure that ga.js has executed if it's injected in this manner? (Another component depends on it) <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol)...

maxi and min times to calculate the Fibonacci numbers for six seperate runs at n [closed]

c++,recursion,iteration,fibonacci,timing
The wording for this problem has me completely confused. I know how to get "timing" using GetTickCount() but I have to repeat the calculation 6 times for each N and I have to have 6 different N and the results have to be reported in one table as max an...

PHP - Could a random sleep prevent timing attacks?

php,security,timing
From Wikipedia In cryptography, a timing attack is a side channel attack in which the attacker attempts to compromise a cryptosystem by analyzing the time taken to execute cryptographic algorithms. Actually, to prevent timing attacks, I'm using the following function taken from this answer: function timingSafeCompare($safe, $user) { // Prevent...

inconsistent timing from .net StopWatch

c#,.net,timing,stopwatch,cudafy.net
I have a C# & .NET application that uses a GPU (NVIDA GTX980) to do image processing. There are 4 stages and I synch the CPU to the GPU (no overlap in time) to do timing. But the numbers do not add up. Launch() will do a async launch of...

c++ - difference between runtime timing function and command line time

c++,timing,difference
I have the following code with the timing function from http://stackoverflow.com/a/1861493/4587344 and the libbsc from https://github.com/IlyaGrebnov/libbsc. #include <vector> #include <iostream> #include <random> #include <cassert> #include <sys/time.h> #include "libbsc/libbsc/libbsc.h" typedef unsigned long long timestamp_t; static timestamp_t get_timestamp () { struct timeval now; gettimeofday (&now, NULL); return now.tv_usec + (timestamp_t)now.tv_sec * 1000000;...

Execute JqueryMobile Popup on Jquery timing event

javascript,jquery,jquery-mobile,timing
I am having trouble attaching a timing event to my function I want this to on execute the function after 25 seconds. what am I doing wrong? setTimeout("ajaxTimeout();", 25000); $(document).on({ //open popup here 'pageshow': function ajaxTimeout(){ $('#askforsomething').popup('open'); } }, '#homepage'); ...

Multiple jQuery slideshows won't stay in sync

javascript,jquery,slideshow,sync,timing
I'm using a simple jQuery script to run a fade-in/out slideshow. (I'm a nubee at jQ.) I am running 3 instances of the slide show to control 3 separate slide areas. The slides are timed with fadeIn, delay and fadeOut. Here are the controlling code lines from each script: slides.eq(slideCount).fadeIn(1000).delay(6000).fadeOut(1000,...

Logical Clocks: Lamport Timestamps

messaging,distributed,clock,timing,distributed-system
I am currently trying to understand Lamport timestamps. Consider two processes P1 (producing events a1, a2,...) and P2 (producing events b1, b2,...). Let C(e) denote the Lamport timestamp associated with event an e. I created timestamps for each event as described in the Wikipedia article about Lamport timestamps: According to...

Time Script Within Header of Page

javascript,php,timing
I need to time a script in my header to only display between 8:00 am and 5:30 PM Monday - Friday. It needs to remain in the header for templating purposes. The script is the following: <head><script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript" src="http://www.example.com/chat/scripts/livechat.js"></script></head> Now I would normally take the following approach, but...

OpenGL, measuring rendering time on gpu

opengl,gpu,timing,opengl-4,elapsedtime
I have some big performance issues here So I would like to take some measurements on the gpu side. By reading this thread I wrote this code around my draw functions, including the gl error check and the swapBuffers() (auto swapping is indeed disabled) gl4.glBeginQuery(GL4.GL_TIME_ELAPSED, queryId[0]); { draw(gl4); checkGlError(gl4); glad.swapBuffers();...

JQuery - Image player issue

javascript,jquery,setinterval,player,timing
I've made a JQuery player for images Demo Link. It changes the screens with provided intervals and draws touches on it. Now, I want to implement pouse, play functionality. When I click on play button to stop screen playing, I call FlowPlaye.stop() method: FlowPlayer.prototype.stop = function() { $(".fp-pause").removeClass("fp-pause").addClass("fp-play"); clearInterval(this.screenIntervalId); clearInterval(this.timeIntervalId);...

Fastest way to check if dataframe is empty [duplicate]

r,data.frame,timing
This question already has an answer here: Determine if data frame is empty 1 answer What is the fastest (every microsecond counts) way to check if a data.frame is empty? I need it in the following context: if (<df is not empty>) { do something here } Possible solutions:...