Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

comparing timestamps

Hello everyone!

I am trying to compare the time of a keyboard response with the begining of a trial. So i am using time.time() function to record the begining of my trial in ms (t0 = time.time()*1000) and i also have later t1 which is the time of the keypress (key, t1 = my_keyboard.get_key()). However i am a bit confused. The t0 value is a number similar to 1709552679902 while the t1 is like  25712. How can i compare these two?


Thank you in advance!

Rania

Comments

  • Hi @rania_tach,

    I believe that you are measuring time using different references. Your t1 is the response time measure by the keyboard object. The time.time() function in Python measures the current time in seconds since the Unix epoch, which is defined as 00:00:00 Coordinated Universal Time (UTC) on January 1, 1970. It returns a floating-point number representing the elapsed time since that epoch. Your 1709552679902 is a number of seconds and corresponds to 54 years, 228 days, 9 hours, 51 minutes, and 42 seconds.

    There are multiple ways of measuring time in Python. Make sure that you verify what each method is actually doing and measuring in reference to.

    Your can achieve what you're after by establishing time stamps using clock.time(). So, for example, you can establish a time stamps at the very beginning of a trial, and then right after the keyboard object, when a response has been registered. If you subtract the first time stamp from the second, you'll have the time elapsed in ms. Note that clock.time() works in the current version of Open Sesame 4.0 because the latter uses Python 3.6. The clock.time() method has been taken out of Python 3.8 and so you may prefer to use the time.perf_counter() function, which works in Python 3.6 and later (that way, if future implementations of Open Sesame upgrade to a later version of Python, your task should still work).

    Alternatively, a simpler method is to use the built-in time stamps of all objects in Open Sesame. You can, using a very simple line of code, calculate the time elapsed between the beginning of the trial and a response using something like this, where you place that calculation right after your keyboard event.

    I attach this basic example where I demonstrate both methods. You'll see that the time.perf_counter() method and that using the time_ property of objects in Open Sesame produce almost exactly the same values (but not exactly, because the time.perf_counter() method establishes the first time stamp when the trial sequence has started, while the previous method starts measuring the time elapsed from the onset of the trial's sequence. There is a difference of about 2 ms on my computer, but this may vary depending on the computer's speed to run the code. In any case, whether you chose one method or the other and stick to it, you shoudl get consistent performance.

    Hope this helps,

    Fabrice.

    Buy Me A Coffee

  • Dear Fab,

    Thank you so much for your response! I understand now the difference between those time measurements. Before trying time.time() function, i had also tried the clock.time() but i got this as a measurement this: <bound method Legacy.time of <openexp._clock.legacy.Legacy object at 0x000001BED70B5A50>>. I use opensesame 4.0 so as you mentioned it should work but i don't know what was the issue. Could it be the back end (i use expyriment)?


    Anyways, the time.perf_counter() function works perfectly so i will probably go with that. And also thank you for the examples and for the alternative method you proposed. I wasn't aware of it and i will definately use it in my experiments.


    Cheers,


    Rania

  • Hi @rania_tach,

    Glad I could help! Good luck with your experiment!

    Cheers,

    Fabrice.

    Buy Me A Coffee

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games