<commit_before>import sys
from os import path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

from utils import *

def test_small_integers(test_case):
    print("Running", "test_small_integers")
    test_case.runAsJava(adjust("""
        for i in range(100):
            for j in range(100):
                x = -5
                for k in range(-5, 257):
                    x = x + 1
        """), timed=True)

def test_booleans(test_case):
    print("Running", "test_booleans")
    test_case.runAsJava(adjust("""
        for i in range(100000):
            x = True
            y = False

            x = (not x and y)
            y = x != y

            x = True and True and True
            y = x or False

            x = not True or (not x) or True
            y = y == y

            x = y != (not x)
            y = False or True or (not y)

            x = (x != x) or (not False)
            y = y and y and (not x)

            x = False or False or False or False
            y = True and True and True and True

            x = 1 != 0
            y = (not (not (not (not (not (not (not x)))))))

            x = ((not y) and y) == ((not (not x)) or y or (not y))
            y = False or False or (not True) or (not True) or (not True)

            x = True and (not False) and True and (not False) and False
            y = (False != False) != False
        """), timed=True)

def test_global_var_load(test_case):
<<<<<<< HEAD:tests/benchmarks.py
    print("Running", "test_global_var_load")
=======
    print("Running", "test_loads")
>>>>>>> optimize method loads:tests/bench_datatypes.py
    test_case.runAsJava(adjust("""
        x = 1
        y = 2

        for i in range(100000):
            print(x)
            print(y)
            print(x+y)
            print(x-y)
            print(x)
            print(y)
            print(x*y)
            print(x/y)
            print(x)
            print(y)
    """), timed=True)

def test_class_var_load(test_case):
<<<<<<< HEAD:tests/benchmarks.py
    print("Running", "test_class_var_load")
=======
    print("Running", "test_method_loads")
>>>>>>> optimize method loads:tests/bench_datatypes.py
    test_case.runAsJava(adjust("""
        class Animal:
            def __init__(self, name, sound):
                self.name = name
                self.sound = sound

            def speak(self):
                print(self.name)
                print(self.sound)
                print(self.name)
                print(self.sound)
                print(self.name)
                print(self.sound)

        lapo = Animal("Lapo", "Bow Wow")
        for i in range(100000):
            lapo.speak()
            lapo.speak()
            lapo.speak()

    """), timed=True)

<<<<<<< HEAD:tests/benchmarks.py
def test_function_var_load(test_case):
    print("Running", "test_function_var_load")
    test_case.runAsJava(adjust("""
        def foo():
            x = 1
            y = 2
            print(x)
            print(y)
            print(x+y)
            print(x-y)
            print(x)
            print(y)
            print(x*y)
            print(x/y)
            print(x)
            print(y)

        for i in range(100000):
            foo()
    """), timed=True)

=======
>>>>>>> optimize method loads:tests/bench_datatypes.py
def main():
    test_case = TranspileTestCase()
    test_case.setUpClass()
    test_small_integers(test_case)
    test_booleans(test_case)
    test_global_var_load(test_case)
    test_class_var_load(test_case)
<<<<<<< HEAD:tests/benchmarks.py
    test_function_var_load(test_case)
=======
>>>>>>> optimize method loads:tests/bench_datatypes.py

if __name__== "__main__":
  main()<commit_msg>rename benchmarking test and add function load test<commit_after>import sys
from os import path
sys.path.append(path.dirname(path.dirname(path.abspath(__file__))))

from utils import *

def test_small_integers(test_case):
    print("Running", "test_small_integers")
    test_case.runAsJava(adjust("""
        for i in range(100):
            for j in range(100):
                x = -5
                for k in range(-5, 257):
                    x = x + 1
        """), timed=True)

def test_booleans(test_case):
    print("Running", "test_booleans")
    test_case.runAsJava(adjust("""
        for i in range(100000):
            x = True
            y = False

            x = (not x and y)
            y = x != y

            x = True and True and True
            y = x or False

            x = not True or (not x) or True
            y = y == y

            x = y != (not x)
            y = False or True or (not y)

            x = (x != x) or (not False)
            y = y and y and (not x)

            x = False or False or False or False
            y = True and True and True and True

            x = 1 != 0
            y = (not (not (not (not (not (not (not x)))))))

            x = ((not y) and y) == ((not (not x)) or y or (not y))
            y = False or False or (not True) or (not True) or (not True)

            x = True and (not False) and True and (not False) and False
            y = (False != False) != False
        """), timed=True)

def test_global_var_load(test_case):
    print("Running", "test_global_var_load")
    test_case.runAsJava(adjust("""
        x = 1
        y = 2

        for i in range(100000):
            print(x)
            print(y)
            print(x+y)
            print(x-y)
            print(x)
            print(y)
            print(x*y)
            print(x/y)
            print(x)
            print(y)
    """), timed=True)

def test_class_var_load(test_case):
    print("Running", "test_class_var_load")
    test_case.runAsJava(adjust("""
        class Animal:
            def __init__(self, name, sound):
                self.name = name
                self.sound = sound

            def speak(self):
                print(self.name)
                print(self.sound)
                print(self.name)
                print(self.sound)
                print(self.name)
                print(self.sound)

        lapo = Animal("Lapo", "Bow Wow")
        for i in range(100000):
            lapo.speak()
            lapo.speak()
            lapo.speak()

    """), timed=True)

def test_function_var_load(test_case):
    print("Running", "test_function_var_load")
    test_case.runAsJava(adjust("""
        def foo():
            x = 1
            y = 2
            print(x)
            print(y)
            print(x+y)
            print(x-y)
            print(x)
            print(y)
            print(x*y)
            print(x/y)
            print(x)
            print(y)

        for i in range(100000):
            foo()
    """), timed=True)

def main():
    test_case = TranspileTestCase()
    test_case.setUpClass()
    test_small_integers(test_case)
    test_booleans(test_case)
    test_global_var_load(test_case)
    test_class_var_load(test_case)
    test_function_var_load(test_case)

if __name__== "__main__":
  main()
{'fraction_non_alphanumeric': 0.12544649235605088, 'fraction_numerical': 0.012001714530647235, 'mean_word_length': 1.6061057334326136, 'pattern_counts': {'":': 2, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2055065', 'n_tokens_mistral': 2316, 'n_tokens_neox': 2179, 'n_words': 568}