summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorMaxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>2021-02-05 15:07:06 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2021-10-20 18:19:28 -0400
commitd2ad0a1175a83392710a4248dc541492ba151e61 (patch)
tree9de955dc3c61adeb4019a9c2848c5f994c4b3beb /misc
parent8357e8e5142b97c452929aade0c24f59c7a34833 (diff)
Added synthetic torture test with 30K tiny methods
Diffstat (limited to 'misc')
-rw-r--r--misc/gen_call_test.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/misc/gen_call_test.rb b/misc/gen_call_test.rb
new file mode 100644
index 0000000000..206beda22e
--- /dev/null
+++ b/misc/gen_call_test.rb
@@ -0,0 +1,47 @@
+NUM_LEVELS = 30
+FNS_PER_LEVEL = 1000
+
+$out = ""
+
+def addln(str = "")
+ $out << str << "\n"
+end
+
+NUM_LEVELS.times do |l_no|
+ FNS_PER_LEVEL.times do |f_no|
+ f_name = "fun_l#{l_no}_n#{f_no}"
+
+ if l_no < NUM_LEVELS - 1
+ callee_no = rand(0...FNS_PER_LEVEL)
+ callee_name = "fun_l#{l_no+1}_n#{callee_no}"
+ else
+ callee_name = "inc"
+ end
+
+ addln("def #{f_name}()")
+ addln(" #{callee_name}")
+ addln("end")
+ addln()
+ end
+end
+
+addln("@a = 0")
+addln("@b = 0")
+addln("@c = 0")
+addln("@d = 0")
+addln("@count = 0")
+addln("def inc()")
+addln(" @count += 1")
+addln("end")
+
+# 100K times
+addln("100000.times do")
+ FNS_PER_LEVEL.times do |f_no|
+ f_name = "fun_l0_n#{f_no}"
+ addln(" #{f_name}")
+ end
+addln("end")
+
+addln("puts @count")
+
+puts($out) \ No newline at end of file