How to measure the total time of experiment

PennController for IBEX Forums Requests How to measure the total time of experiment

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8270
    Da_Ri_
    Participant

    I’m trying to measure a total time that a participant spends on my experiment. I was considering using the following method:

    1. Start timer for measuring a total time

    newVar("ExperimentTime")
       .set( v => Date.now() )

    2. Stop timer for measuring a total time
    getVar("ExperimentTime").set( v => Date.now() - v)

    3. Make a row called ExperimentTime which contains the total time of the experiment
    .log("ExperimentTime", getVar("ExperimentTime"))

    I thought that this would work just like measuring RT, but I’m not sure where I should put these into my code. For instance, if I use a following example code for a self-paced reading experiment, where should I put the codes?

    PennController.ResetPrefix(null); // Shorten command names (keep this line here))
    
    // DebugOff()   // Uncomment this line only when you are 100% done designing your experiment
    
    // First show instructions, then experiment trials, send results and show end screen
    Sequence("instructions", "experiment", SendResults(), "end")
    
    // This is run at the beginning of each trial
    Header(
        // Declare a global Var element "ID" in which we will store the participant's ID
        newVar("ID").global()    
    )
    .log( "id" , getVar("ID") ) // Add the ID to all trials' results lines
    
    // Instructions
    newTrial("instructions",
         // Automatically print all Text elements, centered
        defaultText.center().print()
        ,
        newText("Welcome!")
        ,
        newText("In this task, you will have to read few sentences.")
        ,
        newText("Are you ready?")
        ,
        newText("Please type in your ID below and then click on the Start button to start the experiment.")
        ,
        newTextInput("inputID", "")
            .center()
            .css("margin","1em")    // Add a 1em margin around this element
            .print()
        ,
        newButton("Start")
            .center()
            .print()
            // Only validate a click on Start when inputID has been filled
            .wait( getTextInput("inputID").testNot.text("") )
        ,
        // Store the text from inputID into the Var element
        getVar("ID").set( getTextInput("inputID") )
    )
    
    // First experiment trial
    newTrial( "experiment",
        newText("instructions", "Click on the button below to start reading. Click spacebar to proceed to the next word.")
            .print()
        ,
        newButton("Start reading")
            .print()
            .wait()
            .remove()
        ,
        getText("instructions")
            .remove()
        ,
        // We use the native-Ibex "DashedSentence" controller
        // Documentation at:   https://github.com/addrummond/ibex/blob/master/docs/manual.md#dashedsentence
        newController("DashedSentence", {s : "You have just begun reading the sentence you have just finished reading."})
            .print()
            .log()      // Make sure to log the participant's progress
            .wait()
            .remove()
        ,
        newButton("Next sentence please!")
            .print()
            .wait()
    )
    
    // Second, more concise experiment trial
    newTrial( "experiment",
        newController("DashedSentence", {s : "Time flies like an arrow, but fruit flies like a banana."})
            .print()
            .log()
            .wait()
            .remove()
        ,
        newButton("I'm done")
            .print()
            .wait()
    )
    
    // Final screen
    newTrial("end",
        newText("Thank you for your participation!")
            .center()
            .print()
        ,
        // This link a placeholder: replace it with a URL provided by your participant-pooling platform
        newText("<p><a href='https://www.pcibex.net/' target='_blank' rel="noopener noreferrer">Click here to validate your submission</a></p>")
            .center()
            .print()
        ,
        // Trick: stay on this trial forever (until tab is closed)
        newButton().wait()
    )
    .setOption("countsForProgressBar",false)

    Or if someone has a better idea to measure a total time, I would really appreciate if you can teach me how to do it. Thank you so much.

    • This topic was modified 2 years, 5 months ago by Da_Ri_.
    • This topic was modified 2 years, 5 months ago by Da_Ri_.
    #8273
    Jeremy
    Keymaster

    Hi,

    Since your experiment starts with a PennController trial and ends with one too, and since PennController trials automatically add a line to the results file for the start of the trial and a line for the end of the trial too, simply subtract the EventTime of the first “_Start_” event of the run from the EventTime of the last “_End_” event of the run. No need to use any Var element

    Jeremy

    #8274
    Da_Ri_
    Participant

    Thank you so much for your answer! Now I understand it 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.