the for loop that takes 4 hours.

Update: I finally found a related article:
Update:  Timeit() has a default, and runs the tested method 1 million times!!!!
https://lemire.me/blog/2016/03/21/ranged-random-number-generation-is-slow-in-python/
Apparently Python's randint is kinda slow... and timeit() says it is...   I think there is something in my computer making this happen at a huge rate....

I added some more to my test from the previous test... but here's the loop I tested last night.  I decided it needed it's own post.

I think the math term might be compound.  I think that's whats going on.... When this bug is happening, things are taking twice as long to process it looks like...  300 of these for loops took 1600s about....  so 10* more of those took about 16000s,  I'm not great at math, but It just seems like there's a pattern.   I also tested a little out of my python virtual environment, and it looks like times maybe cut in about half outside of the python environment.... More tests needed.

It's all a good learning experience.  And now That I found a way to do it that won't crash or destroy my gremlins, we can have a peaceful little game of war.

All the tests I did yesterday aren't reliable since the tests might be a product of the flawed method.... but it's still useful.  How do I test what is malfunctioning while this malfunctions?

Anyhoo.... Here's a picture,  and  the little gremlin.   The rest of the test is post 101.   Should be able to just scroll down to see it. If you want to.  NO pressure.... WINK WINK... Nudge nudge....








from random import randint

#alist = []

#this isn't doing anything it was for other tests I ran
def spam(x):
    y = x + 1
    return y

def test_spam():
    for i in range(0, 3000):
        x = randint(0, 10)   

if __name__ == '__main__':
    import timeit
    print(timeit.timeit("test_spam()", setup="from __main__ import test_spam"))










Comments

Popular posts from this blog

playing with color in powershell python

JavaScript Ascii animation with while loops and console.log

playing with trigonometry sin in pygame