Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Timeit module
#8
To be honest, I can't really understand your question, what is 't' and what is 's'?

You mean, that one set should have 1000 random elements and the other set 10,000? This way then:
In [1]: %%timeit
   ...:
   ...: import numpy as np
   ...: SCALE = 1000
   ...: s1 = set( (np.random.rand(1000) * SCALE).astype('int') )
   ...: s2 = set( (np.random.rand(10000) * SCALE).astype('int') )
   ...: s1.intersection(s2)
   ...:
The slowest run took 748.40 times longer than the fastest. This could mean that
an intermediate result is being cached.
1 loop, best of 3: 1.28 ms per loop
Reply


Messages In This Thread
Timeit module - by Miraclefruit - Jan-28-2018, 02:00 AM
RE: Timeit module - by egslava - Jan-28-2018, 02:16 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 02:23 AM
RE: Timeit module - by egslava - Jan-28-2018, 02:27 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 02:29 AM
RE: Timeit module - by snippsat - Jan-28-2018, 03:28 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 03:43 AM
RE: Timeit module - by egslava - Jan-28-2018, 03:48 AM
RE: Timeit module - by snippsat - Jan-28-2018, 04:04 AM
RE: Timeit module - by Miraclefruit - Jan-28-2018, 04:16 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pi modules and %timeit RockBlok 3 640 Dec-09-2023, 04:23 PM
Last Post: RockBlok

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020