ossiejhmoore

OScript : List Iteration -vs- In List -vs- Assoc Is Feature

Jul 18th, 2012
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. output:
  2.  
  3. i took 20453 ticks
  4. i took 10125 ticks
  5. i took 8437 ticks
  6.  
  7. code:
  8.  
  9. function Test()
  10.  
  11. Integer i,j
  12. Integer reps
  13. Integer subtype
  14. Boolean skip
  15. Integer tick
  16.  
  17. List subtypelist = {0, 128, 142, 144, 557}
  18.  
  19. List keepAsList = {144, 557}
  20. Assoc keepAsAssoc = Assoc.CreateAssoc()
  21. keepAsAssoc.(0) = 0
  22. keepAsAssoc.(144) = 144
  23.  
  24.  
  25. tick = Date.Tick()
  26. //test by iterating over the list
  27. for i = 0 to 1000000
  28. skip = true
  29. for subtype in subtypelist
  30. for j in keepAsList
  31. if (j == subtype)
  32. skip = false
  33. break
  34. end
  35. end
  36. end
  37. end
  38. echo("i took ", Date.Tick() - tick, " ticks")
  39.  
  40. tick = Date.Tick()
  41. //test using IsFeature
  42. for i = 0 to 1000000
  43. for subtype in subtypelist
  44. skip = IsFeature(keepAsAssoc, subtype)
  45. end
  46. end
  47. echo("i took ", Date.Tick() - tick, " ticks")
  48.  
  49.  
  50. tick = Date.Tick()
  51. //test using is in list method
  52. for i = 0 to 1000000
  53. for subtype in subtypelist
  54. skip = subtype in keepAsList
  55. end
  56. end
  57. echo("i took ", Date.Tick() - tick, " ticks")
  58.  
  59. end
Advertisement
Add Comment
Please, Sign In to add comment