Results 1 to 5 of 5

Thread: Timing Functions (UserScripts)

  1. #1

    Joined
    Jun 2012
    Posts
    2,236
    Pronouns
    He / Him
    Userbars
    39
    Thanks
    1,472
    Thanked
    2,167/810
    DL/UL
    16/0
    Mentioned
    228 times
    Time Online
    63d 23h 28m
    Avg. Time Online
    22m

    Timing Functions (UserScripts)

    TLDR: What's a good way to time the speed of my script?
    Inside a function or when I call the function?
    I'm currently using performance.now() to time, should I use this?




    I'm working on a main shop ABer and I'm working on solving pet captcha portion.
    I know there's a publicly-available method of solving this captcha but I decided to try to work on my own.

    After completing mine, I believe I might have something that's more accurate and faster.
    The improved accuracy is a certainty, but I want to make sure that my captcha solving function is not slowed down by this.
    How should I measure how long my function takes to solve?



    This is what I'm doing currently:



    Should I be timing when I call the function instead of inside the function itself?





  2. The Following User Says Thank You to Shawn For This Useful Post:

    npm (05-07-2021)

  3. #2
    npm's Avatar
    Joined
    Dec 2011
    Posts
    813
    Userbars
    15
    Thanks
    735
    Thanked
    564/219
    DL/UL
    84/3
    Mentioned
    109 times
    Time Online
    83d 21h 28m
    Avg. Time Online
    28m
    You should be measuring the time outside the function as you're trying to measure the total time until you get the result from the function. Btw great job I never put time into finding an optimal solution for the captcha
    Last edited by npm; 05-07-2021 at 12:42 PM.



    Code:
    404 Not Found.

  4. The Following 2 Users Say Thank You to npm For This Useful Post:

    Mario2302 (05-07-2021),Shawn (05-07-2021)

  5. #3

    Joined
    Jun 2012
    Posts
    2,236
    Pronouns
    He / Him
    Userbars
    39
    Thanks
    1,472
    Thanked
    2,167/810
    DL/UL
    16/0
    Mentioned
    228 times
    Time Online
    63d 23h 28m
    Avg. Time Online
    22m
    Quote Originally Posted by npm View Post
    You should be measuring the time outside the function as you're trying to measure the total time until you get the result from the function. Btw great job I never put time into finding an optimal solution for the captcha
    Thank you, this makes sense.



    Glad to say that I've completed auto-haggle + captcha completion + form submission that completes the buy page consistently in <10ms
    Haggling takes about 0.1 ms
    Solving captcha takes <10 ms
    Practical AB speed really depends on how fast the browser loads haggle form + captcha image.



    I would really LOVE to release this but tbh it's waaaaay too fast to be released for general use here for now.
    I'd need to implement a random delay when buying, which I'll leave for another day.

  6. The Following User Says Thank You to Shawn For This Useful Post:

    npm (05-09-2021)

  7. #4
    Sarada's Avatar
    Joined
    Aug 2017
    Posts
    371
    Userbars
    11
    Thanks
    103
    Thanked
    193/117
    DL/UL
    9/0
    Mentioned
    23 times
    Time Online
    26d 15h 18m
    Avg. Time Online
    15m
    I'm not sure how to time your function or introduce randomized delays, but I suspect if you can create a bell curve randomized time, it would look more human than an even distribution of times. IE if use a bell curve and have a delay between 1 and 9 seconds it'll more often refresh closer to 5 seconds than it will at the extremes of 1 second and 9 seconds.

  8. The Following User Says Thank You to Sarada For This Useful Post:

    Shawn (05-08-2021)

  9. #5

    Joined
    Jun 2012
    Posts
    2,236
    Pronouns
    He / Him
    Userbars
    39
    Thanks
    1,472
    Thanked
    2,167/810
    DL/UL
    16/0
    Mentioned
    228 times
    Time Online
    63d 23h 28m
    Avg. Time Online
    22m
    Quote Originally Posted by Sarada View Post
    I'm not sure how to time your function or introduce randomized delays, but I suspect if you can create a bell curve randomized time, it would look more human than an even distribution of times. IE if use a bell curve and have a delay between 1 and 9 seconds it'll more often refresh closer to 5 seconds than it will at the extremes of 1 second and 9 seconds.
    Yes, I've thought of, and seen easily implementable bell curve distributions of random numbers. Thank you for that suggestion!

    And don't worry, I've got timing my functions down as well as implementing the random delays in the future!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •