<commit_before>
# Benchmarking utility functions

namespace eval bench {

    package require turbine 0.0.2

    package provide bench 0.0.1

    # Set by mpe_setup
    variable mpe_ready

    # MPE event IDs
    variable event

    proc mpe_setup { } {

        variable mpe_ready
        variable event
        set event_names [ list set1 set1rA set1rB sum ]

        if { ! [ info exists mpe_ready ] } {

            foreach e $event_names {
                set L [ mpe::create $e ]
                set event(start_$e) [ lindex $L 0 ]
                set event(stop_$e)  [ lindex $L 1 ]

                set mpe_ready 1
            }
        }
    }

    # usage: set1_float no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1_float { stack result delay } {
        turbine::rule "set1-$result" $delay $turbine::WORK \
            "bench::set1_float_body $result $delay"
    }

    proc set1_float_body { result delay } {

        variable event

        mpe_setup
        set delay_value [ get_float $delay ]
        mpe::log $event(start_set1)
        after [ expr round($delay_value) ]
        mpe::log $event(stop_set1)
        set_integer $result 1
    }

    # usage: set1_integer no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1_integer { stack result delay } {
        turbine::rule "set1-$result" $delay $turbine::WORK \
            "bench::set1_integer_body $result $delay"
    }

    proc set1_integer_body { result delay } {
        set delay_value [ get_integer $delay ]
        after $delay_value
        set_integer $result 1
    }

    # usage: set1_integer no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1rA_integer { stack result delay } {
        turbine::rule "set1r-$result" $delay $turbine::WORK \
            "bench::set1rA_integer_body $result $delay"
    }

    proc set1rA_integer_body { result delay } {

        variable event
        mpe_setup
        set delay_value [ get_integer $delay ]
        # randomized delay value:
        mpe::log $event(start_set1rA)
        set rdv [ expr rand() * $delay_value ]
        after [ expr round($rdv) ]
        mpe::log $event(stop_set1rA)
        set_integer $result 1
    }

    # usage: set1_integer no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1rB_integer { stack result delay } {<commit_msg>New MPE event for debugging<commit_after>
# Benchmarking utility functions

namespace eval bench {

    package require turbine 0.0.2

    package provide bench 0.0.1

    # Set by mpe_setup
    variable mpe_ready

    # MPE event IDs
    variable event

    proc mpe_setup { } {

        variable mpe_ready
        variable event
        set event_names [ list debug set1 set1rA set1rB sum ]

        if { ! [ info exists mpe_ready ] } {

            foreach e $event_names {
                set L [ mpe::create $e ]
                set event(start_$e) [ lindex $L 0 ]
                set event(stop_$e)  [ lindex $L 1 ]

                set mpe_ready 1
            }
        }
    }

    # usage: set1_float no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1_float { stack result delay } {
        turbine::rule "set1-$result" $delay $turbine::WORK \
            "bench::set1_float_body $result $delay"
    }

    proc set1_float_body { result delay } {

        variable event

        mpe_setup
        set delay_value [ get_float $delay ]
        mpe::log $event(start_set1)
        after [ expr round($delay_value) ]
        mpe::log $event(stop_set1)
        set_integer $result 1
    }

    # usage: set1_integer no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1_integer { stack result delay } {
        turbine::rule "set1-$result" $delay $turbine::WORK \
            "bench::set1_integer_body $result $delay"
    }

    proc set1_integer_body { result delay } {
        set delay_value [ get_integer $delay ]
        after $delay_value
        set_integer $result 1
    }

    # usage: set1_integer no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1rA_integer { stack result delay } {
        turbine::rule "set1r-$result" $delay $turbine::WORK \
            "bench::set1rA_integer_body $result $delay"
    }

    proc set1rA_integer_body { result delay } {

        variable event
        mpe_setup
        set delay_value [ get_integer $delay ]
        # randomized delay value:
        mpe::log $event(start_set1rA)
        set rdv [ expr rand() * $delay_value ]
        set rdv [ expr round($rdv) ]
        mpe::log $event(start_debug) "after:$rdv"
        after $rdv
        mpe::log $event(stop_set1rA)
        set_integer $result 1
    }

    # usage: set1_integer no_stack result delay
    # delay in milliseconds: rounded to nearest whole millisecond
    proc set1rB_integer { stack result delay } {
{'fraction_non_alphanumeric': 0.07678606768256481, 'fraction_numerical': 0.01424896101325945, 'mean_word_length': 2.178616352201258, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6396300', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1503, 'n_words': 447}