├── .gitignore ├── LICENSE.md ├── README.md ├── project1 ├── engine.cfg ├── export.cfg ├── icon.png ├── icon.png.flags ├── main.xscn ├── polyfills.gd ├── start.gd ├── test_singleton.gd └── tests │ ├── test.gd │ ├── test_add_remove_node.gd │ ├── test_constants_addition.gd │ ├── test_constants_addition_x10.gd │ ├── test_deep_transform_3d_get.gd │ ├── test_deep_transform_3d_noget.gd │ ├── test_divide.gd │ ├── test_emit_signal.gd │ ├── test_emit_signal_long_name.gd │ ├── test_empty_func.gd │ ├── test_for_time.gd │ ├── test_get_node.gd │ ├── test_get_node_10_children.gd │ ├── test_get_node_10_children_3_deep.gd │ ├── test_if_true.gd │ ├── test_if_true_else.gd │ ├── test_increment.gd │ ├── test_increment_vector2.gd │ ├── test_increment_vector3.gd │ ├── test_increment_vector3_constant.gd │ ├── test_increment_vector3_individual_xyz.gd │ ├── test_increment_with_array_member.gd │ ├── test_increment_with_class_member.gd │ ├── test_increment_with_dictionary_member.gd │ ├── test_increment_with_local_inside_loop.gd │ ├── test_increment_with_local_outside_loop.gd │ ├── test_increment_with_member_var.gd │ ├── test_increment_with_member_var_using_self.gd │ ├── test_increment_x5.gd │ ├── test_int_array_assign.gd │ ├── test_int_array_resize.gd │ ├── test_int_to_string.gd │ ├── test_just_comments.gd │ ├── test_load.gd │ ├── test_new_class.gd │ ├── test_new_class_with_10_members.gd │ ├── test_new_class_with_2_members.gd │ ├── test_new_class_with_long_name.gd │ ├── test_preload.gd │ ├── test_string_concat.gd │ ├── test_string_concat_x10.gd │ ├── test_unused_local.gd │ ├── test_variant_array_assign.gd │ ├── test_variant_array_resize.gd │ └── test_while_time.gd ├── project2 ├── engine.cfg ├── export.cfg ├── icon.png ├── icon.png.flags ├── main.tscn ├── polyfills.gd ├── scale_benchmarks │ ├── bunnymark │ │ ├── bunny.gd │ │ ├── bunny.png │ │ ├── bunny.png.flags │ │ ├── bunny.tscn │ │ ├── bunnymark.gd │ │ └── bunnymark.tscn │ ├── node_spam_with_process │ │ ├── node_spam_with_process.gd │ │ ├── node_spam_with_process.tscn │ │ └── processor.gd │ ├── physics_spheres │ │ ├── physics_spheres.gd │ │ ├── physics_spheres.tscn │ │ └── sphere_body.tscn │ ├── scale_benchmark.gd │ └── sprite_spam │ │ ├── main.gd │ │ └── sprite_spam.tscn ├── start.gd ├── test_singleton.gd └── tests │ ├── test.gd │ ├── test_add_remove_node.gd │ ├── test_constants_addition.gd │ ├── test_constants_addition_x10.gd │ ├── test_deep_transform_3d_get.gd │ ├── test_deep_transform_3d_noget.gd │ ├── test_divide.gd │ ├── test_emit_signal.gd │ ├── test_emit_signal_long_name.gd │ ├── test_empty_func.gd │ ├── test_for_time.gd │ ├── test_get_node.gd │ ├── test_get_node_10_children.gd │ ├── test_get_node_10_children_3_deep.gd │ ├── test_if_true.gd │ ├── test_if_true_else.gd │ ├── test_increment.gd │ ├── test_increment_vector2.gd │ ├── test_increment_vector3.gd │ ├── test_increment_vector3_constant.gd │ ├── test_increment_vector3_individual_xyz.gd │ ├── test_increment_with_array_member.gd │ ├── test_increment_with_class_member.gd │ ├── test_increment_with_dictionary_member.gd │ ├── test_increment_with_local_inside_loop.gd │ ├── test_increment_with_local_outside_loop.gd │ ├── test_increment_with_member_var.gd │ ├── test_increment_with_member_var_using_self.gd │ ├── test_increment_x5.gd │ ├── test_int_array_assign.gd │ ├── test_int_array_resize.gd │ ├── test_int_to_string.gd │ ├── test_just_comments.gd │ ├── test_load.gd │ ├── test_new_class.gd │ ├── test_new_class_with_10_members.gd │ ├── test_new_class_with_2_members.gd │ ├── test_new_class_with_long_name.gd │ ├── test_preload.gd │ ├── test_string_concat.gd │ ├── test_string_concat_x10.gd │ ├── test_unused_local.gd │ ├── test_variant_array_assign.gd │ ├── test_variant_array_resize.gd │ └── test_while_time.gd ├── project3 ├── icon.png ├── icon.png.flags ├── icon.png.import ├── main.tscn ├── polyfills.gd ├── project.godot ├── scale_benchmarks │ ├── bunnymark │ │ ├── bunny.gd │ │ ├── bunny.png │ │ ├── bunny.png.import │ │ ├── bunny.tscn │ │ ├── bunnymark.gd │ │ └── bunnymark.tscn │ ├── cube_spam │ │ ├── cube_spam.gd │ │ └── cube_spam.tscn │ ├── cube_spam_blank_environment │ │ ├── cube_spam_blank_environment.gd │ │ └── cube_spam_blank_environment.tscn │ ├── cube_spam_with_shadows │ │ ├── cube_spam_with_shadows.gd │ │ └── cube_spam_with_shadows.tscn │ ├── node_spam_with_process │ │ ├── node_spam_with_process.gd │ │ ├── node_spam_with_process.tscn │ │ └── processor.gd │ ├── physics_spheres │ │ ├── physics_spheres.gd │ │ ├── physics_spheres.tscn │ │ └── sphere_body.tscn │ ├── scale_benchmark.gd │ └── sprite_spam │ │ ├── sprite_spam.gd │ │ └── sprite_spam.tscn ├── start.gd ├── test_singleton.gd └── tests │ ├── test.gd │ ├── test_add_remove_node.gd │ ├── test_constants_addition.gd │ ├── test_constants_addition_x10.gd │ ├── test_deep_transform_3d_get.gd │ ├── test_deep_transform_3d_noget.gd │ ├── test_divide.gd │ ├── test_emit_signal.gd │ ├── test_emit_signal_long_name.gd │ ├── test_empty_func.gd │ ├── test_for_time.gd │ ├── test_get_node.gd │ ├── test_get_node_10_children.gd │ ├── test_get_node_10_children_3_deep.gd │ ├── test_if_true.gd │ ├── test_if_true_else.gd │ ├── test_increment.gd │ ├── test_increment_vector2.gd │ ├── test_increment_vector3.gd │ ├── test_increment_vector3_constant.gd │ ├── test_increment_vector3_individual_xyz.gd │ ├── test_increment_with_array_member.gd │ ├── test_increment_with_class_member.gd │ ├── test_increment_with_dictionary_member.gd │ ├── test_increment_with_local_inside_loop.gd │ ├── test_increment_with_local_outside_loop.gd │ ├── test_increment_with_member_var.gd │ ├── test_increment_with_member_var_using_self.gd │ ├── test_increment_x5.gd │ ├── test_int_array_assign.gd │ ├── test_int_array_resize.gd │ ├── test_int_to_string.gd │ ├── test_just_comments.gd │ ├── test_load.gd │ ├── test_new_class.gd │ ├── test_new_class_with_10_members.gd │ ├── test_new_class_with_2_members.gd │ ├── test_new_class_with_long_name.gd │ ├── test_preload.gd │ ├── test_string_concat.gd │ ├── test_string_concat_x10.gd │ ├── test_string_format.gd │ ├── test_string_format_x10.gd │ ├── test_unused_local.gd │ ├── test_variant_array_assign.gd │ ├── test_variant_array_resize.gd │ └── test_while_time.gd ├── project31 ├── icon.png ├── icon.png.flags ├── icon.png.import ├── main.tscn ├── polyfills.gd ├── project.godot ├── scale_benchmarks │ ├── bunnymark │ │ ├── bunny.gd │ │ ├── bunny.png │ │ ├── bunny.png.import │ │ ├── bunny.tscn │ │ ├── bunnymark.gd │ │ └── bunnymark.tscn │ ├── cube_spam │ │ ├── cube_spam.gd │ │ └── cube_spam.tscn │ ├── cube_spam_blank_environment │ │ ├── cube_spam_blank_environment.gd │ │ └── cube_spam_blank_environment.tscn │ ├── cube_spam_with_shadows │ │ ├── cube_spam_with_shadows.gd │ │ └── cube_spam_with_shadows.tscn │ ├── node_spam_with_process │ │ ├── node_spam_with_process.gd │ │ ├── node_spam_with_process.tscn │ │ └── processor.gd │ ├── physics_spheres │ │ ├── physics_spheres.gd │ │ ├── physics_spheres.tscn │ │ └── sphere_body.tscn │ ├── scale_benchmark.gd │ └── sprite_spam │ │ ├── sprite_spam.gd │ │ └── sprite_spam.tscn ├── start.gd ├── test_singleton.gd └── tests │ ├── test.gd │ ├── test_add_remove_node.gd │ ├── test_constants_addition.gd │ ├── test_constants_addition_x10.gd │ ├── test_constants_addition_x10_typed.gd │ ├── test_deep_transform_3d_get.gd │ ├── test_deep_transform_3d_noget.gd │ ├── test_divide.gd │ ├── test_divide_typed.gd │ ├── test_emit_signal.gd │ ├── test_emit_signal_long_name.gd │ ├── test_empty_func.gd │ ├── test_engine_func.gd │ ├── test_engine_func_typed.gd │ ├── test_engine_func_with_params.gd │ ├── test_engine_func_with_params_typed.gd │ ├── test_for_time.gd │ ├── test_func_with_params.gd │ ├── test_func_with_params_typed.gd │ ├── test_get_node.gd │ ├── test_get_node_10_children.gd │ ├── test_get_node_10_children_3_deep.gd │ ├── test_if_true.gd │ ├── test_if_true_else.gd │ ├── test_increment.gd │ ├── test_increment_typed.gd │ ├── test_increment_vector2.gd │ ├── test_increment_vector3.gd │ ├── test_increment_vector3_constant.gd │ ├── test_increment_vector3_individual_xyz.gd │ ├── test_increment_with_array_member.gd │ ├── test_increment_with_class_member.gd │ ├── test_increment_with_class_member_typed.gd │ ├── test_increment_with_dictionary_member.gd │ ├── test_increment_with_local_inside_loop.gd │ ├── test_increment_with_local_outside_loop.gd │ ├── test_increment_with_member_var.gd │ ├── test_increment_with_member_var_using_self.gd │ ├── test_increment_x5.gd │ ├── test_increment_x5_typed.gd │ ├── test_int_array_assign.gd │ ├── test_int_array_resize.gd │ ├── test_int_to_string.gd │ ├── test_just_comments.gd │ ├── test_load.gd │ ├── test_new_class.gd │ ├── test_new_class_with_10_members.gd │ ├── test_new_class_with_2_members.gd │ ├── test_new_class_with_long_name.gd │ ├── test_preload.gd │ ├── test_string_concat.gd │ ├── test_string_concat_x10.gd │ ├── test_string_concat_x10_str_vararg.gd │ ├── test_string_format.gd │ ├── test_string_format_x10.gd │ ├── test_unused_local.gd │ ├── test_variant_array_assign.gd │ ├── test_variant_array_resize.gd │ └── test_while_time.gd ├── project32 ├── icon.png ├── icon.png.flags ├── icon.png.import ├── main.tscn ├── polyfills.gd ├── project.godot ├── scale_benchmarks │ ├── bunnymark │ │ ├── bunny.gd │ │ ├── bunny.png │ │ ├── bunny.png.import │ │ ├── bunny.tscn │ │ ├── bunnymark.gd │ │ └── bunnymark.tscn │ ├── cube_spam │ │ ├── cube_spam.gd │ │ └── cube_spam.tscn │ ├── cube_spam_blank_environment │ │ ├── cube_spam_blank_environment.gd │ │ └── cube_spam_blank_environment.tscn │ ├── cube_spam_with_shadows │ │ ├── cube_spam_with_shadows.gd │ │ └── cube_spam_with_shadows.tscn │ ├── node_spam_with_process │ │ ├── node_spam_with_process.gd │ │ ├── node_spam_with_process.tscn │ │ └── processor.gd │ ├── physics_spheres │ │ ├── physics_spheres.gd │ │ ├── physics_spheres.tscn │ │ └── sphere_body.tscn │ ├── scale_benchmark.gd │ └── sprite_spam │ │ ├── sprite_spam.gd │ │ └── sprite_spam.tscn ├── start.gd ├── test_singleton.gd └── tests │ ├── test.gd │ ├── test_add_remove_node.gd │ ├── test_constants_addition.gd │ ├── test_constants_addition_x10.gd │ ├── test_constants_addition_x10_typed.gd │ ├── test_deep_transform_3d_get.gd │ ├── test_deep_transform_3d_noget.gd │ ├── test_divide.gd │ ├── test_divide_typed.gd │ ├── test_emit_signal.gd │ ├── test_emit_signal_long_name.gd │ ├── test_empty_func.gd │ ├── test_engine_func.gd │ ├── test_engine_func_typed.gd │ ├── test_engine_func_with_params.gd │ ├── test_engine_func_with_params_typed.gd │ ├── test_for_time.gd │ ├── test_func_with_params.gd │ ├── test_func_with_params_typed.gd │ ├── test_get_node.gd │ ├── test_get_node_10_children.gd │ ├── test_get_node_10_children_3_deep.gd │ ├── test_get_node_10_children_3_deep_dollar.gd │ ├── test_if_true.gd │ ├── test_if_true_else.gd │ ├── test_image_get_pixel.gd │ ├── test_image_set_pixel.gd │ ├── test_increment.gd │ ├── test_increment_typed.gd │ ├── test_increment_vector2.gd │ ├── test_increment_vector3.gd │ ├── test_increment_vector3_constant.gd │ ├── test_increment_vector3_individual_xyz.gd │ ├── test_increment_with_array_member.gd │ ├── test_increment_with_class_member.gd │ ├── test_increment_with_class_member_typed.gd │ ├── test_increment_with_dictionary_member.gd │ ├── test_increment_with_local_inside_loop.gd │ ├── test_increment_with_local_outside_loop.gd │ ├── test_increment_with_member_var.gd │ ├── test_increment_with_member_var_using_self.gd │ ├── test_increment_x5.gd │ ├── test_increment_x5_typed.gd │ ├── test_int_array_assign.gd │ ├── test_int_array_resize.gd │ ├── test_int_to_string.gd │ ├── test_just_comments.gd │ ├── test_load.gd │ ├── test_new_class.gd │ ├── test_new_class_with_10_members.gd │ ├── test_new_class_with_2_members.gd │ ├── test_new_class_with_long_name.gd │ ├── test_preload.gd │ ├── test_string_concat.gd │ ├── test_string_concat_x10.gd │ ├── test_string_concat_x10_str_vararg.gd │ ├── test_string_format.gd │ ├── test_string_format_x10.gd │ ├── test_unused_local.gd │ ├── test_variant_array_assign.gd │ ├── test_variant_array_resize.gd │ └── test_while_time.gd ├── project4 ├── icon.svg ├── icon.svg.import ├── main.tscn ├── project.godot ├── scale_benchmarks │ ├── bunnymark │ │ ├── bunny.gd │ │ ├── bunny.png │ │ ├── bunny.png.import │ │ ├── bunny.tscn │ │ ├── bunnymark.gd │ │ └── bunnymark.tscn │ ├── cube_spam │ │ ├── cube_spam.gd │ │ └── cube_spam.tscn │ ├── cube_spam_blank_environment │ │ ├── cube_spam_blank_environment.gd │ │ └── cube_spam_blank_environment.tscn │ ├── cube_spam_with_shadows │ │ ├── cube_spam_with_shadows.gd │ │ └── cube_spam_with_shadows.tscn │ ├── node_spam_with_process │ │ ├── node_spam_with_process.gd │ │ ├── node_spam_with_process.tscn │ │ └── processor.gd │ ├── physics_spheres │ │ ├── physics_spheres.gd │ │ ├── physics_spheres.tscn │ │ └── sphere_body.tscn │ ├── scale_benchmark.gd │ ├── sprite_spam │ │ ├── sprite.png │ │ ├── sprite.png.import │ │ ├── sprite_spam.gd │ │ └── sprite_spam.tscn │ └── unique_cube_spam_blank_environment │ │ ├── unique_cube_spam_blank_environment.gd │ │ └── unique_cube_spam_blank_environment.tscn ├── start.gd ├── test_singleton.gd ├── tests │ ├── test.gd │ ├── test_add_remove_node.gd │ ├── test_constants_addition.gd │ ├── test_constants_addition_x10.gd │ ├── test_constants_addition_x10_typed.gd │ ├── test_deep_transform_3d_get.gd │ ├── test_deep_transform_3d_noget.gd │ ├── test_dictionary_lookup_int.gd │ ├── test_dictionary_lookup_nodepath.gd │ ├── test_dictionary_lookup_string.gd │ ├── test_dictionary_lookup_stringname.gd │ ├── test_divide.gd │ ├── test_divide_typed.gd │ ├── test_emit_signal.gd │ ├── test_emit_signal_long_name.gd │ ├── test_emit_signal_long_name_stringname.gd │ ├── test_emit_signal_v2.gd │ ├── test_empty_func.gd │ ├── test_engine_func.gd │ ├── test_engine_func_typed.gd │ ├── test_engine_func_with_params.gd │ ├── test_engine_func_with_params_typed.gd │ ├── test_engine_func_with_params_vcall.gd │ ├── test_for_time.gd │ ├── test_func_with_params.gd │ ├── test_func_with_params_callable.gd │ ├── test_func_with_params_typed.gd │ ├── test_get_node.gd │ ├── test_get_node_10_children.gd │ ├── test_get_node_10_children_3_deep.gd │ ├── test_get_node_10_children_3_deep_dollar.gd │ ├── test_get_node_10_children_3_deep_nodepath.gd │ ├── test_get_node_nodepath.gd │ ├── test_if_true.gd │ ├── test_if_true_else.gd │ ├── test_image_get_pixel.gd │ ├── test_image_set_pixel.gd │ ├── test_increment.gd │ ├── test_increment_typed.gd │ ├── test_increment_vector2.gd │ ├── test_increment_vector3.gd │ ├── test_increment_vector3_constant.gd │ ├── test_increment_vector3_individual_xyz.gd │ ├── test_increment_with_array_member.gd │ ├── test_increment_with_array_member_typed.gd │ ├── test_increment_with_class_member.gd │ ├── test_increment_with_class_member_typed.gd │ ├── test_increment_with_dictionary_member.gd │ ├── test_increment_with_local_inside_loop.gd │ ├── test_increment_with_local_outside_loop.gd │ ├── test_increment_with_member_var.gd │ ├── test_increment_with_member_var_using_self.gd │ ├── test_increment_x5.gd │ ├── test_increment_x5_typed.gd │ ├── test_int_array_assign.gd │ ├── test_int_array_resize.gd │ ├── test_int_to_string.gd │ ├── test_iterate_node_children_x100_get_child.gd │ ├── test_iterate_node_children_x100_get_children.gd │ ├── test_iterate_node_children_x10_get_child.gd │ ├── test_iterate_node_children_x10_get_children.gd │ ├── test_just_comments.gd │ ├── test_load.gd │ ├── test_new_class.gd │ ├── test_new_class_with_10_members.gd │ ├── test_new_class_with_2_members.gd │ ├── test_new_class_with_long_name.gd │ ├── test_preload.gd │ ├── test_selection_with_callable_array.gd │ ├── test_selection_with_if.gd │ ├── test_selection_with_match.gd │ ├── test_string_concat.gd │ ├── test_string_concat_x10.gd │ ├── test_string_concat_x10_str_vararg.gd │ ├── test_string_format.gd │ ├── test_string_format_x10.gd │ ├── test_unused_local.gd │ ├── test_variant_array_assign.gd │ ├── test_variant_array_resize.gd │ └── test_while_time.gd └── util.gd ├── results ├── Godot_v1.1_stable_win64.json ├── Godot_v2.0.4.1_stable_win64.json ├── Godot_v2.0.4_stable_win64.json ├── Godot_v2.1-stable_win64.json ├── Godot_v2.1.1-stable_win64.json ├── Godot_v2.1.2-stable_win64.json ├── Godot_v2.1.3-stable_win64.json ├── Godot_v2.1.4-beta_20170625_win64.json ├── Godot_v2.1.4-beta_20170731_win64.json ├── Godot_v2.1.4-stable_win64.json ├── Godot_v2.1.5-beta1_win64.json ├── Godot_v2.1.5-rc1_win64.json ├── Godot_v2.1.5-rc2_win64.json ├── Godot_v2.1.5-stable_win64.json ├── Godot_v2.1_beta_20160712_win64.json ├── Godot_v2.1_rc1_win64.json ├── Godot_v2.1_rc2_win64.json ├── Godot_v3.0-alpha1_win64.json ├── Godot_v3.0-alpha2_win64.json ├── Godot_v3.0-beta1_win64.json ├── Godot_v3.0-beta2_win64.json ├── Godot_v3.0-rc1_win64.json ├── Godot_v3.0-rc2_win64.json ├── Godot_v3.0-rc3_win64.json ├── Godot_v3.0-stable_win64.json ├── Godot_v3.0.1-rc1_win64.json ├── Godot_v3.0.1-stable_win64.json ├── Godot_v3.0.2-stable_win64.json ├── Godot_v3.0.3-rc1_win64.json ├── Godot_v3.0.3-rc3_win64.json ├── Godot_v3.0.3-stable_win64.json ├── Godot_v3.0.4-stable_win64.json ├── Godot_v3.0.5-stable_win64.json ├── Godot_v3.0.6-stable_win64.json ├── Godot_v3.1-alpha1_win64.json ├── Godot_v3.1-alpha2_win64.json ├── Godot_v3.1-alpha3_win64.json ├── Godot_v3.1-alpha4_win64.json ├── Godot_v3.1-alpha5_win64.json ├── Godot_v3.1-beta10_win64.json ├── Godot_v3.1-beta11_win64.json ├── Godot_v3.1-beta1_win64.json ├── Godot_v3.1-beta2_win64.json ├── Godot_v3.1-beta3_win64.json ├── Godot_v3.1-beta4_win64.json ├── Godot_v3.1-beta5_win64.json ├── Godot_v3.1-beta6_win64.json ├── Godot_v3.1-beta7_win64.json ├── Godot_v3.1-beta8_win64.json ├── Godot_v3.1-beta9_win64.json ├── Godot_v3.1-rc1_win64.json ├── Godot_v3.1-rc2_win64.json ├── Godot_v3.1-rc3_win64.json ├── Godot_v3.1-stable_win64.json ├── Godot_v3.1.1-stable_win64.json ├── Godot_v3.1.2-stable_win64.json ├── Godot_v3.2-alpha1_win64.json ├── Godot_v3.2-alpha2_win64.json ├── Godot_v3.2-alpha3_win64.json ├── Godot_v3.2-beta1_win64.json ├── Godot_v3.2-beta2_win64.json ├── Godot_v3.2-beta3_win64.json ├── Godot_v3.2-beta4_win64.json ├── Godot_v3.2-beta5_win64.json ├── Godot_v3.2-beta6_win64.json ├── Godot_v3.2-rc1_win64.json ├── Godot_v3.2-rc2_win64.json ├── Godot_v3.2-rc3_win64.json ├── Godot_v3.2-rc4_win64.json ├── Godot_v3.2-stable_win64.json ├── godot_2_0_0.json ├── godot_2_0_2.json └── godot_2_0_3.json ├── run.py └── viewer ├── chart.gd ├── icon.png ├── icon.png.import ├── main.gd ├── main.tscn ├── micro_benchmarks_viewer.gd ├── project.godot ├── scale_benchmark_viewer.tscn ├── scale_benchmarks_viewer.gd └── util.gd /.gitignore: -------------------------------------------------------------------------------- 1 | .import/ 2 | .fscache 3 | .godot/ 4 | results.json 5 | -------------------------------------------------------------------------------- /project1/engine.cfg: -------------------------------------------------------------------------------- 1 | [application] 2 | 3 | name="GDScriptPerformance" 4 | main_scene="res://main.xscn" 5 | target_fps=60 6 | icon="res://icon.png" 7 | -------------------------------------------------------------------------------- /project1/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project1/icon.png -------------------------------------------------------------------------------- /project1/icon.png.flags: -------------------------------------------------------------------------------- 1 | gen_mipmaps=false 2 | -------------------------------------------------------------------------------- /project1/polyfills.gd: -------------------------------------------------------------------------------- 1 | # This test suite should be useable on many Godot versions, 2 | # because one goal of this test suite is to be able to compare them 3 | 4 | 5 | static func is_instance_of(a, klass): 6 | return a extends klass 7 | 8 | 9 | static func get_time_msec(): 10 | return OS.get_ticks_msec() 11 | 12 | 13 | static func is_debug_build(): 14 | return OS.is_debug_build() 15 | 16 | 17 | static func get_extension(s): 18 | return s.extension() 19 | 20 | 21 | static func convert_to_json(d): 22 | return d.to_json() 23 | -------------------------------------------------------------------------------- /project1/start.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Node 3 | 4 | func _ready(): 5 | var s = load("res://test_singleton.gd").new() 6 | add_child(s) 7 | s.begin_tests() 8 | get_tree().quit() -------------------------------------------------------------------------------- /project1/tests/test.gd: -------------------------------------------------------------------------------- 1 | 2 | # Set by the main test script 3 | var ITERATIONS = null 4 | var tree_root = null 5 | 6 | # var description = "Test base class" 7 | 8 | func can_run(context): 9 | return true 10 | 11 | 12 | func should_subtract_loop_duration(): 13 | return true 14 | 15 | 16 | func setup(): 17 | pass 18 | 19 | 20 | func execute(): 21 | pass 22 | 23 | -------------------------------------------------------------------------------- /project1/tests/test_add_remove_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add and remove node" 4 | 5 | 6 | func setup(): 7 | ITERATIONS /= 50 8 | 9 | 10 | func execute(): 11 | 12 | var root = tree_root 13 | var node = Node.new() 14 | 15 | for i in range(0, ITERATIONS): 16 | root.add_child(node) 17 | root.remove_child(node) 18 | 19 | node.free() 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /project1/tests/test_constants_addition.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add two constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | 8 | func execute(): 9 | for i in range(0,ITERATIONS): 10 | var x = CONST01 + CONST02 11 | -------------------------------------------------------------------------------- /project1/tests/test_constants_addition_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | const CONST03 = 0 8 | const CONST04 = 0 9 | const CONST05 = 0 10 | const CONST06 = 0 11 | const CONST07 = 0 12 | const CONST08 = 0 13 | const CONST09 = 0 14 | const CONST10 = 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project1/tests/test_deep_transform_3d_noget.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change without querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var root = tree_root 11 | for d in range(0, 10): 12 | var s = Spatial.new() 13 | s.set_name("Spatial") 14 | root.add_child(s) 15 | root = s 16 | _leaf_spatial = s 17 | _root_spatial = tree_root.get_node("Spatial") 18 | 19 | 20 | func execute(): 21 | var root = _root_spatial 22 | 23 | var t1 = Transform(Matrix3(), Vector3(1, 2, 3)) 24 | var t2 = Transform(Matrix3().rotated(Vector3(0, 1, 0), 33), Vector3()) 25 | 26 | var iterations = ITERATIONS / 2 27 | 28 | for i in range(0, iterations): 29 | root.set_transform(t1) 30 | root.set_transform(t2) 31 | -------------------------------------------------------------------------------- /project1/tests/test_divide.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide" 4 | 5 | func execute(): 6 | var a = 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project1/tests/test_emit_signal.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal" 4 | 5 | #signal test_signal 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal") 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_emit_signal_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal with very long name" 4 | 5 | #signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_empty_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Empty func (void function call cost)" 5 | 6 | 7 | func execute(): 8 | for i in range(0,ITERATIONS): 9 | empty_func() 10 | 11 | 12 | func empty_func(): 13 | pass 14 | 15 | -------------------------------------------------------------------------------- /project1/tests/test_for_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "For time (one very long for)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | for i in range(0, ITERATIONS): 12 | pass 13 | -------------------------------------------------------------------------------- /project1/tests/test_get_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where only one child" 4 | 5 | 6 | func setup(): 7 | var node = Node.new() 8 | node.set_name("GetNodeTest") 9 | tree_root.add_child(node) 10 | 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | tree_root.get_node("GetNodeTest") 15 | -------------------------------------------------------------------------------- /project1/tests/test_get_node_10_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where 10 children" 4 | 5 | 6 | func setup(): 7 | for i in range(0, 10): 8 | var n = Node.new() 9 | n.set_name("GetNodeTest_" + str(i)) 10 | tree_root.add_child(n) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node("GetNodeTest_9") 16 | -------------------------------------------------------------------------------- /project1/tests/test_get_node_10_children_3_deep.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() 3 parents deep having 10 children" 4 | 5 | 6 | func setup(): 7 | var root = tree_root 8 | for d in range(0, 3): 9 | for i in range(0, 10): 10 | var n = Node.new() 11 | n.set_name("GetNodeTest_" + str(i)) 12 | root.add_child(n) 13 | root = root.get_node("GetNodeTest_9") 14 | 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | tree_root.get_node("GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 19 | -------------------------------------------------------------------------------- /project1/tests/test_if_true.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true) time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | 10 | -------------------------------------------------------------------------------- /project1/tests/test_if_true_else.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true)else time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | else: 10 | pass 11 | -------------------------------------------------------------------------------- /project1/tests/test_increment.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project1/tests/test_increment_vector2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector2" 4 | 5 | func execute(): 6 | var a = Vector2(0,0) 7 | var b = Vector2(1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_increment_vector3.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3" 4 | 5 | 6 | func execute(): 7 | var a = Vector3(0,0,0) 8 | var b = Vector3(1,1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += b 12 | -------------------------------------------------------------------------------- /project1/tests/test_increment_vector3_constant.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Increment Vector3 with constant" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += Vector3(1,1,1) 12 | -------------------------------------------------------------------------------- /project1/tests/test_increment_vector3_individual_xyz.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3 coordinate by coordinate" 4 | 5 | func execute(): 6 | var a = Vector3(0,0,0) 7 | var b = Vector3(1,1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a.x += b.x 11 | a.y += b.y 12 | a.z += b.z 13 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_array_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with array member" 4 | 5 | func execute(): 6 | var a = 0 7 | var arr = [1] 8 | for i in range(0, ITERATIONS): 9 | a += arr[0] 10 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_class_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member" 4 | 5 | class TestClassForMemberAccess: 6 | var x = 0 7 | 8 | func execute(): 9 | var a = 0 10 | var c = TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_dictionary_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with dictionary member" 4 | 5 | 6 | func execute(): 7 | var a = 0 8 | var dic = {b = 1} 9 | for i in range(0,ITERATIONS): 10 | a += dic.b 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_local_inside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (inside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | 8 | for i in range(0, ITERATIONS): 9 | var b = 1 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_local_outside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (outside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | var b = 1 8 | 9 | for i in range(0,ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_member_var.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += _test_a 12 | 13 | -------------------------------------------------------------------------------- /project1/tests/test_increment_with_member_var_using_self.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var using self" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += self._test_a 12 | 13 | -------------------------------------------------------------------------------- /project1/tests/test_increment_x5.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5)" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project1/tests/test_int_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray set element" 4 | 5 | func execute(): 6 | var i_array = IntArray() 7 | i_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | i_array[42] = 0 11 | -------------------------------------------------------------------------------- /project1/tests/test_int_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = IntArray() 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project1/tests/test_int_to_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String str(i)" 4 | 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | str(i) 9 | 10 | -------------------------------------------------------------------------------- /project1/tests/test_just_comments.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Just 20 lines of comments (should take zero time on release build)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | # Comment 1 8 | # Comment 2 9 | # Comment 3 10 | # Comment 4 11 | # Comment 5 12 | # Comment 6 13 | # Comment 7 14 | # Comment 8 15 | # Comment 9 16 | # Comment 10 17 | # Comment 11 18 | # Comment 12 19 | # Comment 13 20 | # Comment 14 21 | # Comment 15 22 | # Comment 16 23 | # Comment 17 24 | # Comment 18 25 | # Comment 19 26 | # Comment 20 27 | pass 28 | 29 | -------------------------------------------------------------------------------- /project1/tests/test_load.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of load() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | # Godot 1.1 apparently cannot load with relative path... 8 | var res = load("res://tests/test.gd") 9 | 10 | for i in range(0, ITERATIONS): 11 | load("res://tests/test.gd") 12 | 13 | -------------------------------------------------------------------------------- /project1/tests/test_new_class.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (no member variables)" 4 | 5 | 6 | class TestClass1: 7 | func foo(): 8 | pass 9 | 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass1.new() 14 | -------------------------------------------------------------------------------- /project1/tests/test_new_class_with_10_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (10 member variables)" 4 | 5 | class TestClass10: 6 | var v0 = 0 7 | var v1 = 0 8 | var v2 = 0 9 | var v3 = 0 10 | var v4 = 0 11 | var v5 = 0 12 | var v6 = 0 13 | var v7 = 0 14 | var v8 = 0 15 | var v9 = 0 16 | func foo(): 17 | pass 18 | 19 | func execute(): 20 | for i in range(0, ITERATIONS): 21 | TestClass10.new() 22 | -------------------------------------------------------------------------------- /project1/tests/test_new_class_with_2_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (2 member variables)" 4 | 5 | class TestClass2: 6 | var x = 0 7 | var y = 0 8 | func foo(): 9 | pass 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass2.new() 14 | -------------------------------------------------------------------------------- /project1/tests/test_new_class_with_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class with long name (no member variables)" 4 | 5 | class TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName: 6 | func foo(): 7 | pass 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName.new() 12 | 13 | -------------------------------------------------------------------------------- /project1/tests/test_preload.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of preload() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = preload("test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | preload("test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project1/tests/test_string_concat.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 1 number" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc" + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project1/tests/test_string_concat_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a)+ " abc " + str(a) + " abc " + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project1/tests/test_unused_local.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Unused local (declaration cost)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var b = 1 8 | -------------------------------------------------------------------------------- /project1/tests/test_variant_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray set element" 4 | 5 | func execute(): 6 | var v_array = [] 7 | v_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | v_array[42] = 0 11 | -------------------------------------------------------------------------------- /project1/tests/test_variant_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = [] 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project1/tests/test_while_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "While time (one very long while)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | var i = 0 12 | while i < ITERATIONS: 13 | i += 1 14 | -------------------------------------------------------------------------------- /project2/engine.cfg: -------------------------------------------------------------------------------- 1 | [application] 2 | 3 | name="GDScriptPerformance" 4 | main_scene="res://main.tscn" 5 | target_fps=60 6 | icon="res://icon.png" 7 | 8 | [rasterizer] 9 | 10 | max_render_elements=65536 11 | -------------------------------------------------------------------------------- /project2/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project2/icon.png -------------------------------------------------------------------------------- /project2/icon.png.flags: -------------------------------------------------------------------------------- 1 | gen_mipmaps=false 2 | -------------------------------------------------------------------------------- /project2/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=1] 2 | 3 | [ext_resource path="res://start.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | 7 | script/script = ExtResource( 1 ) 8 | 9 | 10 | -------------------------------------------------------------------------------- /project2/polyfills.gd: -------------------------------------------------------------------------------- 1 | # This test suite should be useable on many Godot versions, 2 | # because one goal of this test suite is to be able to compare them 3 | 4 | 5 | static func is_instance_of(a, klass): 6 | return a extends klass 7 | 8 | 9 | static func get_time_msec(): 10 | return OS.get_ticks_msec() 11 | 12 | 13 | static func is_debug_build(): 14 | return OS.is_debug_build() 15 | 16 | 17 | static func get_extension(s): 18 | return s.extension() 19 | 20 | 21 | static func convert_to_json(d): 22 | return d.to_json() 23 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/bunnymark/bunny.gd: -------------------------------------------------------------------------------- 1 | extends Sprite 2 | 3 | 4 | var vx = randi() % 200 + 50 5 | var vy = randi() % 200 + 50 6 | var ay = 980 7 | 8 | 9 | func _ready(): 10 | set_pos(Vector2(50, 50)) 11 | set_process(true) 12 | 13 | 14 | func _process(delta): 15 | var pos = get_pos() 16 | 17 | pos.x = pos.x + vx * delta 18 | pos.y = pos.y + vy * delta 19 | 20 | vy = vy + ay * delta 21 | 22 | if pos.x > 800: 23 | vx = -vx 24 | pos.x = 800 25 | 26 | if pos.x < 0: 27 | vx = abs(vx) 28 | pos.x = 0 29 | 30 | if pos.y > 600: 31 | vy = -0.85 * vy 32 | pos.y = 600 33 | if randf() > 0.5: 34 | vy = -(randi() % 1100 + 50) 35 | 36 | if pos.y < 0: 37 | vy = 0 38 | pos.y = 0 39 | 40 | set_pos(pos) 41 | 42 | 43 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/bunnymark/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project2/scale_benchmarks/bunnymark/bunny.png -------------------------------------------------------------------------------- /project2/scale_benchmarks/bunnymark/bunny.png.flags: -------------------------------------------------------------------------------- 1 | filter=false 2 | gen_mipmaps=false 3 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/bunnymark/bunny.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=1] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.png" type="Texture" id=1] 4 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.gd" type="Script" id=2] 5 | 6 | [node name="Sprite" type="Sprite"] 7 | 8 | texture = ExtResource( 1 ) 9 | script/script = ExtResource( 2 ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/bunnymark/bunnymark.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Bunnymark" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of bunnies" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | for i in range(0, 10): 18 | var bunny_scene = load("res://scale_benchmarks/bunnymark/bunny.tscn") 19 | var bunny = bunny_scene.instance() 20 | add_child(bunny) 21 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/bunnymark/bunnymark.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=1] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunnymark.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | 7 | script/script = ExtResource( 1 ) 8 | __meta__ = { "__editor_plugin_screen__":"Script" } 9 | 10 | 11 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/node_spam_with_process/node_spam_with_process.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Nodes with empty process function" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of processing nodes" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var processor_scene = load("res://scale_benchmarks/node_spam_with_process/processor.gd") 18 | for i in range(0, 1000): 19 | var processor = processor_scene.new() 20 | add_child(processor) 21 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/node_spam_with_process/node_spam_with_process.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=1] 2 | 3 | [ext_resource path="res://scale_benchmarks/node_spam_with_process/node_spam_with_process.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | 7 | script/script = ExtResource( 1 ) 8 | 9 | 10 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/node_spam_with_process/processor.gd: -------------------------------------------------------------------------------- 1 | extends Node 2 | 3 | 4 | func _ready(): 5 | set_process(true) 6 | 7 | 8 | func _process(delta): 9 | pass 10 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/physics_spheres/physics_spheres.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming spheres with physics" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of spheres" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() - 7 14 | 15 | 16 | func process(delta): 17 | var scene = load("res://scale_benchmarks/physics_spheres/sphere_body.tscn") 18 | for i in range(0, 1): 19 | var s = scene.instance() 20 | s.set_translation(Vector3(rand_range(-1, 1), 50, rand_range(-1, 1))) 21 | add_child(s) 22 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/sprite_spam/main.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming sprites" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of sprites" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var tex = load("res://icon.png") 18 | for i in range(0, 100): 19 | var sprite = Sprite.new() 20 | sprite.set_texture(tex) 21 | sprite.set_pos(Vector2(rand_range(100, 400), rand_range(100, 400))) 22 | add_child(sprite) 23 | -------------------------------------------------------------------------------- /project2/scale_benchmarks/sprite_spam/sprite_spam.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=1] 2 | 3 | [ext_resource path="res://scale_benchmarks/sprite_spam/main.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | 7 | script/script = ExtResource( 1 ) 8 | 9 | 10 | -------------------------------------------------------------------------------- /project2/start.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Node 3 | 4 | func _ready(): 5 | var s = load("res://test_singleton.gd").new() 6 | add_child(s) 7 | s.begin_tests() 8 | get_tree().quit() -------------------------------------------------------------------------------- /project2/tests/test.gd: -------------------------------------------------------------------------------- 1 | 2 | # Set by the main test script 3 | var ITERATIONS = null 4 | var tree_root = null 5 | 6 | # var description = "Test base class" 7 | 8 | func can_run(context): 9 | return true 10 | 11 | 12 | func should_subtract_loop_duration(): 13 | return true 14 | 15 | 16 | func setup(): 17 | pass 18 | 19 | 20 | func execute(): 21 | pass 22 | 23 | -------------------------------------------------------------------------------- /project2/tests/test_add_remove_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add and remove node" 4 | 5 | 6 | func setup(): 7 | ITERATIONS /= 50 8 | 9 | 10 | func execute(): 11 | 12 | var root = tree_root 13 | var node = Node.new() 14 | 15 | for i in range(0, ITERATIONS): 16 | root.add_child(node) 17 | root.remove_child(node) 18 | 19 | node.free() 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /project2/tests/test_constants_addition.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add two constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | 8 | func execute(): 9 | for i in range(0,ITERATIONS): 10 | var x = CONST01 + CONST02 11 | -------------------------------------------------------------------------------- /project2/tests/test_constants_addition_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | const CONST03 = 0 8 | const CONST04 = 0 9 | const CONST05 = 0 10 | const CONST06 = 0 11 | const CONST07 = 0 12 | const CONST08 = 0 13 | const CONST09 = 0 14 | const CONST10 = 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project2/tests/test_deep_transform_3d_noget.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change without querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var root = tree_root 11 | for d in range(0, 10): 12 | var s = Spatial.new() 13 | s.set_name("Spatial") 14 | root.add_child(s) 15 | root = s 16 | _leaf_spatial = s 17 | _root_spatial = tree_root.get_node("Spatial") 18 | 19 | 20 | func execute(): 21 | var root = _root_spatial 22 | 23 | var t1 = Transform(Matrix3(), Vector3(1, 2, 3)) 24 | var t2 = Transform(Matrix3().rotated(Vector3(0, 1, 0), 33), Vector3()) 25 | 26 | var iterations = ITERATIONS / 2 27 | 28 | for i in range(0, iterations): 29 | root.set_transform(t1) 30 | root.set_transform(t2) 31 | -------------------------------------------------------------------------------- /project2/tests/test_divide.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide" 4 | 5 | func execute(): 6 | var a = 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project2/tests/test_emit_signal.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal" 4 | 5 | signal test_signal 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal") 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_emit_signal_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal with very long name" 4 | 5 | signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_empty_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Empty func (void function call cost)" 5 | 6 | 7 | func execute(): 8 | for i in range(0,ITERATIONS): 9 | empty_func() 10 | 11 | 12 | func empty_func(): 13 | pass 14 | 15 | -------------------------------------------------------------------------------- /project2/tests/test_for_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "For time (one very long for)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | for i in range(0, ITERATIONS): 12 | pass 13 | -------------------------------------------------------------------------------- /project2/tests/test_get_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where only one child" 4 | 5 | 6 | func setup(): 7 | var node = Node.new() 8 | node.set_name("GetNodeTest") 9 | tree_root.add_child(node) 10 | 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | tree_root.get_node("GetNodeTest") 15 | -------------------------------------------------------------------------------- /project2/tests/test_get_node_10_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where 10 children" 4 | 5 | 6 | func setup(): 7 | for i in range(0, 10): 8 | var n = Node.new() 9 | n.set_name("GetNodeTest_" + str(i)) 10 | tree_root.add_child(n) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node("GetNodeTest_9") 16 | -------------------------------------------------------------------------------- /project2/tests/test_get_node_10_children_3_deep.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() 3 parents deep having 10 children" 4 | 5 | 6 | func setup(): 7 | var root = tree_root 8 | for d in range(0, 3): 9 | for i in range(0, 10): 10 | var n = Node.new() 11 | n.set_name("GetNodeTest_" + str(i)) 12 | root.add_child(n) 13 | root = root.get_node("GetNodeTest_9") 14 | 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | tree_root.get_node("GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 19 | -------------------------------------------------------------------------------- /project2/tests/test_if_true.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true) time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | 10 | -------------------------------------------------------------------------------- /project2/tests/test_if_true_else.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true)else time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | else: 10 | pass 11 | -------------------------------------------------------------------------------- /project2/tests/test_increment.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project2/tests/test_increment_vector2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector2" 4 | 5 | func execute(): 6 | var a = Vector2(0,0) 7 | var b = Vector2(1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_increment_vector3.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3" 4 | 5 | 6 | func execute(): 7 | var a = Vector3(0,0,0) 8 | var b = Vector3(1,1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += b 12 | -------------------------------------------------------------------------------- /project2/tests/test_increment_vector3_constant.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Increment Vector3 with constant" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += Vector3(1,1,1) 12 | -------------------------------------------------------------------------------- /project2/tests/test_increment_vector3_individual_xyz.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3 coordinate by coordinate" 4 | 5 | func execute(): 6 | var a = Vector3(0,0,0) 7 | var b = Vector3(1,1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a.x += b.x 11 | a.y += b.y 12 | a.z += b.z 13 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_array_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with array member" 4 | 5 | func execute(): 6 | var a = 0 7 | var arr = [1] 8 | for i in range(0, ITERATIONS): 9 | a += arr[0] 10 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_class_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member" 4 | 5 | class TestClassForMemberAccess: 6 | var x = 0 7 | 8 | func execute(): 9 | var a = 0 10 | var c = TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_dictionary_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with dictionary member" 4 | 5 | 6 | func execute(): 7 | var a = 0 8 | var dic = {b = 1} 9 | for i in range(0,ITERATIONS): 10 | a += dic.b 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_local_inside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (inside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | 8 | for i in range(0, ITERATIONS): 9 | var b = 1 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_local_outside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (outside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | var b = 1 8 | 9 | for i in range(0,ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_member_var.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += _test_a 12 | 13 | -------------------------------------------------------------------------------- /project2/tests/test_increment_with_member_var_using_self.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var using self" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += self._test_a 12 | 13 | -------------------------------------------------------------------------------- /project2/tests/test_increment_x5.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5)" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project2/tests/test_int_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray set element" 4 | 5 | func execute(): 6 | var i_array = IntArray() 7 | i_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | i_array[42] = 0 11 | -------------------------------------------------------------------------------- /project2/tests/test_int_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = IntArray() 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project2/tests/test_int_to_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String str(i)" 4 | 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | str(i) 9 | 10 | -------------------------------------------------------------------------------- /project2/tests/test_just_comments.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Just 20 lines of comments (should take zero time on release build)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | # Comment 1 8 | # Comment 2 9 | # Comment 3 10 | # Comment 4 11 | # Comment 5 12 | # Comment 6 13 | # Comment 7 14 | # Comment 8 15 | # Comment 9 16 | # Comment 10 17 | # Comment 11 18 | # Comment 12 19 | # Comment 13 20 | # Comment 14 21 | # Comment 15 22 | # Comment 16 23 | # Comment 17 24 | # Comment 18 25 | # Comment 19 26 | # Comment 20 27 | pass 28 | 29 | -------------------------------------------------------------------------------- /project2/tests/test_load.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of load() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = load("res://tests/test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | load("res://tests/test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_new_class.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (no member variables)" 4 | 5 | 6 | class TestClass1: 7 | func foo(): 8 | pass 9 | 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass1.new() 14 | -------------------------------------------------------------------------------- /project2/tests/test_new_class_with_10_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (10 member variables)" 4 | 5 | class TestClass10: 6 | var v0 = 0 7 | var v1 = 0 8 | var v2 = 0 9 | var v3 = 0 10 | var v4 = 0 11 | var v5 = 0 12 | var v6 = 0 13 | var v7 = 0 14 | var v8 = 0 15 | var v9 = 0 16 | func foo(): 17 | pass 18 | 19 | func execute(): 20 | for i in range(0, ITERATIONS): 21 | TestClass10.new() 22 | -------------------------------------------------------------------------------- /project2/tests/test_new_class_with_2_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (2 member variables)" 4 | 5 | class TestClass2: 6 | var x = 0 7 | var y = 0 8 | func foo(): 9 | pass 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass2.new() 14 | -------------------------------------------------------------------------------- /project2/tests/test_new_class_with_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class with long name (no member variables)" 4 | 5 | class TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName: 6 | func foo(): 7 | pass 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName.new() 12 | 13 | -------------------------------------------------------------------------------- /project2/tests/test_preload.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of preload() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = preload("test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | preload("test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project2/tests/test_string_concat.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 1 number" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc" + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project2/tests/test_string_concat_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a)+ " abc " + str(a) + " abc " + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project2/tests/test_unused_local.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Unused local (declaration cost)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var b = 1 8 | -------------------------------------------------------------------------------- /project2/tests/test_variant_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray set element" 4 | 5 | func execute(): 6 | var v_array = [] 7 | v_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | v_array[42] = 0 11 | -------------------------------------------------------------------------------- /project2/tests/test_variant_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = [] 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project2/tests/test_while_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "While time (one very long while)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | var i = 0 12 | while i < ITERATIONS: 13 | i += 1 14 | -------------------------------------------------------------------------------- /project3/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project3/icon.png -------------------------------------------------------------------------------- /project3/icon.png.flags: -------------------------------------------------------------------------------- 1 | gen_mipmaps=false 2 | -------------------------------------------------------------------------------- /project3/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | 7 | [deps] 8 | 9 | source_file="res://icon.png" 10 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 11 | 12 | [params] 13 | 14 | compress/mode=0 15 | compress/lossy_quality=0.7 16 | compress/hdr_mode=0 17 | compress/normal_map=0 18 | flags/repeat=0 19 | flags/filter=true 20 | flags/mipmaps=false 21 | flags/anisotropic=false 22 | flags/srgb=2 23 | process/fix_alpha_border=true 24 | process/premult_alpha=false 25 | process/HDR_as_SRGB=false 26 | stream=false 27 | size_limit=0 28 | detect_3d=true 29 | svg/scale=1.0 30 | -------------------------------------------------------------------------------- /project3/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://start.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | 7 | script = ExtResource( 1 ) 8 | 9 | 10 | -------------------------------------------------------------------------------- /project3/polyfills.gd: -------------------------------------------------------------------------------- 1 | # This test suite should be useable on many Godot versions, 2 | # because one goal of this test suite is to be able to compare them 3 | 4 | 5 | static func is_instance_of(a, klass): 6 | return a is klass 7 | 8 | 9 | static func get_time_msec(): 10 | return OS.get_ticks_msec() 11 | 12 | 13 | static func is_debug_build(): 14 | return OS.is_debug_build() 15 | 16 | 17 | static func get_extension(s): 18 | return s.get_extension() 19 | 20 | 21 | static func convert_to_json(d): 22 | return to_json(d) 23 | -------------------------------------------------------------------------------- /project3/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=3 10 | 11 | [application] 12 | 13 | config/name="Nouveau projet de jeu" 14 | run/main_scene="res://main.tscn" 15 | config/icon="res://icon.png" 16 | 17 | [gdnative] 18 | 19 | singletons=[ ] 20 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/bunnymark/bunny.gd: -------------------------------------------------------------------------------- 1 | extends Sprite 2 | 3 | 4 | var vx = randi() % 200 + 50 5 | var vy = randi() % 200 + 50 6 | var ay = 980 7 | 8 | 9 | func _ready(): 10 | set_position(Vector2(50, 50)) 11 | set_process(true) 12 | 13 | 14 | func _process(delta): 15 | var pos = get_position() 16 | 17 | pos.x = pos.x + vx * delta 18 | pos.y = pos.y + vy * delta 19 | 20 | vy = vy + ay * delta 21 | 22 | if pos.x > 800: 23 | vx = -vx 24 | pos.x = 800 25 | 26 | if pos.x < 0: 27 | vx = abs(vx) 28 | pos.x = 0 29 | 30 | if pos.y > 600: 31 | vy = -0.85 * vy 32 | pos.y = 600 33 | if randf() > 0.5: 34 | vy = -(randi() % 1100 + 50) 35 | 36 | if pos.y < 0: 37 | vy = 0 38 | pos.y = 0 39 | 40 | set_position(pos) 41 | 42 | 43 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/bunnymark/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project3/scale_benchmarks/bunnymark/bunny.png -------------------------------------------------------------------------------- /project3/scale_benchmarks/bunnymark/bunny.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/bunny.png-b9bb18bcf5e2838b2b16bd5993c7957e.stex" 6 | 7 | [deps] 8 | 9 | source_file="res://scale_benchmarks/bunnymark/bunny.png" 10 | dest_files=[ "res://.import/bunny.png-b9bb18bcf5e2838b2b16bd5993c7957e.stex" ] 11 | 12 | [params] 13 | 14 | compress/mode=0 15 | compress/lossy_quality=0.7 16 | compress/hdr_mode=0 17 | compress/normal_map=0 18 | flags/repeat=0 19 | flags/filter=false 20 | flags/mipmaps=false 21 | flags/anisotropic=false 22 | flags/srgb=2 23 | process/fix_alpha_border=true 24 | process/premult_alpha=false 25 | process/HDR_as_SRGB=false 26 | stream=false 27 | size_limit=0 28 | detect_3d=true 29 | svg/scale=1.0 30 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/bunnymark/bunny.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.png" type="Texture" id=1] 4 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.gd" type="Script" id=2] 5 | 6 | [node name="Bunny" type="Sprite" index="0"] 7 | 8 | texture = ExtResource( 1 ) 9 | script = ExtResource( 2 ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/bunnymark/bunnymark.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Bunnymark" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of bunnies" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | for i in range(0, 10): 18 | var bunny_scene = load("res://scale_benchmarks/bunnymark/bunny.tscn") 19 | var bunny = bunny_scene.instance() 20 | add_child(bunny) 21 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/bunnymark/bunnymark.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunnymark.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/cube_spam/cube_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/cube_spam_blank_environment/cube_spam_blank_environment.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/cube_spam_with_shadows/cube_spam_with_shadows.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/node_spam_with_process/node_spam_with_process.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Nodes with empty process function" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of processing nodes" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var processor_scene = load("res://scale_benchmarks/node_spam_with_process/processor.gd") 18 | for i in range(0, 1000): 19 | var processor = processor_scene.new() 20 | add_child(processor) 21 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/node_spam_with_process/node_spam_with_process.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/node_spam_with_process/node_spam_with_process.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/node_spam_with_process/processor.gd: -------------------------------------------------------------------------------- 1 | extends Node 2 | 3 | 4 | func _ready(): 5 | set_process(true) 6 | 7 | 8 | func _process(delta): 9 | pass 10 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/physics_spheres/physics_spheres.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming spheres with physics" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of spheres" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() - 7 14 | 15 | 16 | func process(delta): 17 | var scene = load("res://scale_benchmarks/physics_spheres/sphere_body.tscn") 18 | for i in range(0, 1): 19 | var s = scene.instance() 20 | s.set_translation(Vector3(rand_range(-1, 1), 50, rand_range(-1, 1))) 21 | add_child(s) 22 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/sprite_spam/sprite_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming sprites" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of sprites" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var tex = load("res://icon.png") 18 | for i in range(0, 100): 19 | var sprite = Sprite.new() 20 | sprite.set_texture(tex) 21 | sprite.set_position(Vector2(rand_range(100, 400), rand_range(100, 400))) 22 | add_child(sprite) 23 | -------------------------------------------------------------------------------- /project3/scale_benchmarks/sprite_spam/sprite_spam.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/sprite_spam/sprite_spam.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project3/start.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Node 3 | 4 | func _ready(): 5 | var s = load("res://test_singleton.gd").new() 6 | add_child(s) 7 | s.begin_tests() 8 | get_tree().quit() 9 | 10 | 11 | -------------------------------------------------------------------------------- /project3/tests/test.gd: -------------------------------------------------------------------------------- 1 | 2 | # Set by the main test script 3 | var ITERATIONS = null 4 | var tree_root = null 5 | 6 | # var description = "Test base class" 7 | 8 | func can_run(context): 9 | return true 10 | 11 | 12 | func should_subtract_loop_duration(): 13 | return true 14 | 15 | 16 | func setup(): 17 | pass 18 | 19 | 20 | func execute(): 21 | pass 22 | 23 | -------------------------------------------------------------------------------- /project3/tests/test_add_remove_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add and remove node" 4 | 5 | 6 | func setup(): 7 | ITERATIONS /= 50 8 | 9 | 10 | func execute(): 11 | 12 | var root = tree_root 13 | var node = Node.new() 14 | 15 | # NOTE: I found this test is biased, and I can't do anything about it. 16 | # Godot appears to run it slower if there are more iterations. 17 | # Adding and removing nodes has a race condition over the time it takes. 18 | 19 | for i in range(0, ITERATIONS): 20 | root.add_child(node) 21 | root.remove_child(node) 22 | 23 | node.free() 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /project3/tests/test_constants_addition.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add two constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | 8 | func execute(): 9 | for i in range(0,ITERATIONS): 10 | var x = CONST01 + CONST02 11 | -------------------------------------------------------------------------------- /project3/tests/test_constants_addition_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | const CONST03 = 0 8 | const CONST04 = 0 9 | const CONST05 = 0 10 | const CONST06 = 0 11 | const CONST07 = 0 12 | const CONST08 = 0 13 | const CONST09 = 0 14 | const CONST10 = 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project3/tests/test_deep_transform_3d_get.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var parent = tree_root 11 | 12 | for d in 10: 13 | var child = Spatial.new() 14 | child.set_name("Spatial") 15 | parent.add_child(child) 16 | _leaf_spatial = child 17 | parent = child 18 | 19 | _root_spatial = tree_root.get_node("Spatial") 20 | 21 | 22 | func execute(): 23 | var root = _root_spatial 24 | var leaf = _leaf_spatial 25 | 26 | var t1 = Transform(Basis(), Vector3(1, 2, 3)) 27 | var t2 = Transform(Basis().rotated(Vector3(0, 1, 0), 33), Vector3()) 28 | 29 | var iterations = ITERATIONS / 2 30 | 31 | for i in range(0, iterations): 32 | root.set_transform(t1) 33 | leaf.get_global_transform() 34 | root.set_transform(t2) 35 | leaf.get_global_transform() 36 | -------------------------------------------------------------------------------- /project3/tests/test_deep_transform_3d_noget.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change without querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var root = tree_root 11 | for d in 10: 12 | var s = Spatial.new() 13 | s.set_name("Spatial") 14 | root.add_child(s) 15 | root = s 16 | _leaf_spatial = s 17 | _root_spatial = tree_root.get_node("Spatial") 18 | 19 | 20 | func execute(): 21 | var root = _root_spatial 22 | 23 | var t1 = Transform(Basis(), Vector3(1, 2, 3)) 24 | var t2 = Transform(Basis().rotated(Vector3(0, 1, 0), 33), Vector3()) 25 | 26 | var iterations = ITERATIONS / 2 27 | 28 | for i in range(0, iterations): 29 | root.set_transform(t1) 30 | root.set_transform(t2) 31 | -------------------------------------------------------------------------------- /project3/tests/test_divide.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide" 4 | 5 | func execute(): 6 | var a = 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project3/tests/test_emit_signal.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal" 4 | 5 | signal test_signal 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal") 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_emit_signal_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal with very long name" 4 | 5 | signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_empty_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Empty func (void function call cost)" 5 | 6 | 7 | func execute(): 8 | for i in range(0,ITERATIONS): 9 | empty_func() 10 | 11 | 12 | func empty_func(): 13 | pass 14 | 15 | -------------------------------------------------------------------------------- /project3/tests/test_for_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "For time (one very long for)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | for i in range(0, ITERATIONS): 12 | pass 13 | -------------------------------------------------------------------------------- /project3/tests/test_get_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where only one child" 4 | 5 | 6 | func setup(): 7 | var node = Node.new() 8 | node.set_name("GetNodeTest") 9 | tree_root.add_child(node) 10 | 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | tree_root.get_node("GetNodeTest") 15 | -------------------------------------------------------------------------------- /project3/tests/test_get_node_10_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where 10 children" 4 | 5 | 6 | func setup(): 7 | for i in 10: 8 | var n = Node.new() 9 | n.set_name("GetNodeTest_" + str(i)) 10 | tree_root.add_child(n) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node("GetNodeTest_9") 16 | -------------------------------------------------------------------------------- /project3/tests/test_get_node_10_children_3_deep.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() 3 parents deep having 10 children" 4 | 5 | 6 | func setup(): 7 | var root = tree_root 8 | for d in 3: 9 | for i in 10: 10 | var n = Node.new() 11 | n.set_name("GetNodeTest_" + str(i)) 12 | root.add_child(n) 13 | root = root.get_node("GetNodeTest_9") 14 | 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | tree_root.get_node("GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 19 | -------------------------------------------------------------------------------- /project3/tests/test_if_true.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true) time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | 10 | -------------------------------------------------------------------------------- /project3/tests/test_if_true_else.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true)else time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | else: 10 | pass 11 | -------------------------------------------------------------------------------- /project3/tests/test_increment.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project3/tests/test_increment_vector2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector2" 4 | 5 | func execute(): 6 | var a = Vector2(0,0) 7 | var b = Vector2(1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_increment_vector3.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3" 4 | 5 | 6 | func execute(): 7 | var a = Vector3(0,0,0) 8 | var b = Vector3(1,1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += b 12 | -------------------------------------------------------------------------------- /project3/tests/test_increment_vector3_constant.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Increment Vector3 with constant" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += Vector3(1,1,1) 12 | -------------------------------------------------------------------------------- /project3/tests/test_increment_vector3_individual_xyz.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3 coordinate by coordinate" 4 | 5 | func execute(): 6 | var a = Vector3(0,0,0) 7 | var b = Vector3(1,1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a.x += b.x 11 | a.y += b.y 12 | a.z += b.z 13 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_array_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with array member" 4 | 5 | func execute(): 6 | var a = 0 7 | var arr = [1] 8 | for i in range(0, ITERATIONS): 9 | a += arr[0] 10 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_class_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member" 4 | 5 | class TestClassForMemberAccess: 6 | var x = 0 7 | 8 | func execute(): 9 | var a = 0 10 | var c = TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_dictionary_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with dictionary member" 4 | 5 | 6 | func execute(): 7 | var a = 0 8 | var dic = {b = 1} 9 | for i in range(0,ITERATIONS): 10 | a += dic.b 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_local_inside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (inside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | 8 | for i in range(0, ITERATIONS): 9 | var b = 1 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_local_outside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (outside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | var b = 1 8 | 9 | for i in range(0,ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_member_var.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += _test_a 12 | 13 | -------------------------------------------------------------------------------- /project3/tests/test_increment_with_member_var_using_self.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var using self" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += self._test_a 12 | 13 | -------------------------------------------------------------------------------- /project3/tests/test_increment_x5.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5)" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project3/tests/test_int_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray set element" 4 | 5 | func execute(): 6 | var i_array = PoolIntArray() 7 | i_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | i_array[42] = 0 11 | -------------------------------------------------------------------------------- /project3/tests/test_int_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = PoolIntArray() 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project3/tests/test_int_to_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String str(i)" 4 | 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | str(i) 9 | 10 | -------------------------------------------------------------------------------- /project3/tests/test_just_comments.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Just 20 lines of comments (should take zero time on release build)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | # Comment 1 8 | # Comment 2 9 | # Comment 3 10 | # Comment 4 11 | # Comment 5 12 | # Comment 6 13 | # Comment 7 14 | # Comment 8 15 | # Comment 9 16 | # Comment 10 17 | # Comment 11 18 | # Comment 12 19 | # Comment 13 20 | # Comment 14 21 | # Comment 15 22 | # Comment 16 23 | # Comment 17 24 | # Comment 18 25 | # Comment 19 26 | # Comment 20 27 | pass 28 | 29 | -------------------------------------------------------------------------------- /project3/tests/test_load.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of load() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = load("res://tests/test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | load("res://tests/test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_new_class.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (no member variables)" 4 | 5 | 6 | class TestClass1: 7 | func foo(): 8 | pass 9 | 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass1.new() 14 | -------------------------------------------------------------------------------- /project3/tests/test_new_class_with_10_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (10 member variables)" 4 | 5 | class TestClass10: 6 | var v0 = 0 7 | var v1 = 0 8 | var v2 = 0 9 | var v3 = 0 10 | var v4 = 0 11 | var v5 = 0 12 | var v6 = 0 13 | var v7 = 0 14 | var v8 = 0 15 | var v9 = 0 16 | func foo(): 17 | pass 18 | 19 | func execute(): 20 | for i in range(0, ITERATIONS): 21 | TestClass10.new() 22 | -------------------------------------------------------------------------------- /project3/tests/test_new_class_with_2_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (2 member variables)" 4 | 5 | class TestClass2: 6 | var x = 0 7 | var y = 0 8 | func foo(): 9 | pass 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass2.new() 14 | -------------------------------------------------------------------------------- /project3/tests/test_new_class_with_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class with long name (no member variables)" 4 | 5 | class TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName: 6 | func foo(): 7 | pass 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName.new() 12 | 13 | -------------------------------------------------------------------------------- /project3/tests/test_preload.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of preload() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = preload("test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | preload("test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project3/tests/test_string_concat.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 1 number" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc" + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project3/tests/test_string_concat_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers" 4 | 5 | 6 | func setup(): 7 | # That test is quite long 8 | ITERATIONS /= 2 9 | 10 | 11 | func execute(): 12 | var a = 42 13 | for i in range(0, ITERATIONS): 14 | "abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a)+ " abc " + str(a) + " abc " + str(a) 15 | 16 | -------------------------------------------------------------------------------- /project3/tests/test_string_format.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String format with 1 number" 4 | 5 | func can_run(context): 6 | var v = context.engine_version.major 7 | return v != "1" and v != "2" 8 | 9 | 10 | func execute(): 11 | var a = 42 12 | for i in range(0, ITERATIONS): 13 | "abc {0}".format([a]) 14 | -------------------------------------------------------------------------------- /project3/tests/test_string_format_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String format with 10 numbers" 4 | 5 | func can_run(context): 6 | var v = context.engine_version.major 7 | return v != "1" and v != "2" 8 | 9 | 10 | func setup(): 11 | # This test takes long 12 | ITERATIONS /= 5 13 | 14 | 15 | func execute(): 16 | var a = 42 17 | for i in range(0, ITERATIONS): 18 | "abc {0} abc {1} abc {2} abc {3} abc {4} abc {5} abc {6} abc {7} abc {8} abc {9}".format([a,a,a,a,a,a,a,a,a,a]) 19 | -------------------------------------------------------------------------------- /project3/tests/test_unused_local.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Unused local (declaration cost)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var b = 1 8 | -------------------------------------------------------------------------------- /project3/tests/test_variant_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray set element" 4 | 5 | func execute(): 6 | var v_array = [] 7 | v_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | v_array[42] = 0 11 | -------------------------------------------------------------------------------- /project3/tests/test_variant_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = [] 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project3/tests/test_while_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "While time (one very long while)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | var i = 0 12 | while i < ITERATIONS: 13 | i += 1 14 | -------------------------------------------------------------------------------- /project31/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project31/icon.png -------------------------------------------------------------------------------- /project31/icon.png.flags: -------------------------------------------------------------------------------- 1 | gen_mipmaps=false 2 | -------------------------------------------------------------------------------- /project31/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /project31/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://start.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | script = ExtResource( 1 ) 7 | 8 | -------------------------------------------------------------------------------- /project31/polyfills.gd: -------------------------------------------------------------------------------- 1 | # This test suite should be useable on many Godot versions, 2 | # because one goal of this test suite is to be able to compare them 3 | 4 | 5 | static func is_instance_of(a, klass): 6 | return a is klass 7 | 8 | 9 | static func get_time_msec(): 10 | return OS.get_ticks_msec() 11 | 12 | 13 | static func is_debug_build(): 14 | return OS.is_debug_build() 15 | 16 | 17 | static func get_extension(s): 18 | return s.get_extension() 19 | 20 | 21 | static func convert_to_json(d): 22 | return to_json(d) 23 | -------------------------------------------------------------------------------- /project31/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ ] 12 | _global_script_class_icons={ 13 | 14 | } 15 | 16 | [application] 17 | 18 | config/name="Nouveau projet de jeu" 19 | run/main_scene="res://main.tscn" 20 | config/icon="res://icon.png" 21 | 22 | [gdnative] 23 | 24 | singletons=[ ] 25 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/bunnymark/bunny.gd: -------------------------------------------------------------------------------- 1 | extends Sprite 2 | 3 | 4 | var vx = randi() % 200 + 50 5 | var vy = randi() % 200 + 50 6 | var ay = 980 7 | 8 | 9 | func _ready(): 10 | set_position(Vector2(50, 50)) 11 | set_process(true) 12 | 13 | 14 | func _process(delta): 15 | var pos = get_position() 16 | 17 | pos.x = pos.x + vx * delta 18 | pos.y = pos.y + vy * delta 19 | 20 | vy = vy + ay * delta 21 | 22 | if pos.x > 800: 23 | vx = -vx 24 | pos.x = 800 25 | 26 | if pos.x < 0: 27 | vx = abs(vx) 28 | pos.x = 0 29 | 30 | if pos.y > 600: 31 | vy = -0.85 * vy 32 | pos.y = 600 33 | if randf() > 0.5: 34 | vy = -(randi() % 1100 + 50) 35 | 36 | if pos.y < 0: 37 | vy = 0 38 | pos.y = 0 39 | 40 | set_position(pos) 41 | 42 | 43 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/bunnymark/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project31/scale_benchmarks/bunnymark/bunny.png -------------------------------------------------------------------------------- /project31/scale_benchmarks/bunnymark/bunny.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/bunny.png-b9bb18bcf5e2838b2b16bd5993c7957e.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://scale_benchmarks/bunnymark/bunny.png" 13 | dest_files=[ "res://.import/bunny.png-b9bb18bcf5e2838b2b16bd5993c7957e.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=false 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/bunnymark/bunny.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.png" type="Texture" id=1] 4 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.gd" type="Script" id=2] 5 | 6 | [node name="Bunny" type="Sprite" index="0"] 7 | 8 | texture = ExtResource( 1 ) 9 | script = ExtResource( 2 ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/bunnymark/bunnymark.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Bunnymark" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of bunnies" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | for i in range(0, 10): 18 | var bunny_scene = load("res://scale_benchmarks/bunnymark/bunny.tscn") 19 | var bunny = bunny_scene.instance() 20 | add_child(bunny) 21 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/bunnymark/bunnymark.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunnymark.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node"] 7 | script = ExtResource( 1 ) 8 | 9 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/cube_spam/cube_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/cube_spam_blank_environment/cube_spam_blank_environment.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/cube_spam_with_shadows/cube_spam_with_shadows.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/node_spam_with_process/node_spam_with_process.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Nodes with empty process function" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of processing nodes" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var processor_scene = load("res://scale_benchmarks/node_spam_with_process/processor.gd") 18 | for i in range(0, 1000): 19 | var processor = processor_scene.new() 20 | add_child(processor) 21 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/node_spam_with_process/node_spam_with_process.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/node_spam_with_process/node_spam_with_process.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/node_spam_with_process/processor.gd: -------------------------------------------------------------------------------- 1 | extends Node 2 | 3 | 4 | func _ready(): 5 | set_process(true) 6 | 7 | 8 | func _process(delta): 9 | pass 10 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/physics_spheres/physics_spheres.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming spheres with physics" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of spheres" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() - 7 14 | 15 | 16 | func process(delta): 17 | var scene = load("res://scale_benchmarks/physics_spheres/sphere_body.tscn") 18 | for i in range(0, 1): 19 | var s = scene.instance() 20 | s.set_translation(Vector3(rand_range(-1, 1), 50, rand_range(-1, 1))) 21 | add_child(s) 22 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/physics_spheres/sphere_body.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [sub_resource type="SphereShape" id=1] 4 | 5 | 6 | [sub_resource type="SphereMesh" id=2] 7 | 8 | radial_segments = 8 9 | rings = 4 10 | 11 | [node name="SphereBody" type="RigidBody"] 12 | 13 | [node name="CollisionShape" type="CollisionShape" parent="."] 14 | shape = SubResource( 1 ) 15 | 16 | [node name="MeshInstance" type="MeshInstance" parent="."] 17 | visible = false 18 | mesh = SubResource( 2 ) 19 | material/0 = null 20 | 21 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/sprite_spam/sprite_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming sprites" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of sprites" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var tex = load("res://icon.png") 18 | for i in range(0, 100): 19 | var sprite = Sprite.new() 20 | sprite.set_texture(tex) 21 | sprite.set_position(Vector2(rand_range(100, 400), rand_range(100, 400))) 22 | add_child(sprite) 23 | -------------------------------------------------------------------------------- /project31/scale_benchmarks/sprite_spam/sprite_spam.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/sprite_spam/sprite_spam.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project31/start.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Node 3 | 4 | func _ready(): 5 | var s = load("res://test_singleton.gd").new() 6 | add_child(s) 7 | s.begin_tests() 8 | get_tree().quit() 9 | 10 | 11 | -------------------------------------------------------------------------------- /project31/tests/test.gd: -------------------------------------------------------------------------------- 1 | 2 | # Set by the main test script 3 | var ITERATIONS = null 4 | var tree_root = null 5 | 6 | # var description = "Test base class" 7 | 8 | func can_run(context): 9 | return true 10 | 11 | 12 | func should_subtract_loop_duration(): 13 | return true 14 | 15 | 16 | func setup(): 17 | pass 18 | 19 | 20 | func execute(): 21 | pass 22 | 23 | -------------------------------------------------------------------------------- /project31/tests/test_add_remove_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add and remove node" 4 | 5 | 6 | func setup(): 7 | ITERATIONS /= 50 8 | 9 | 10 | func execute(): 11 | 12 | var root = tree_root 13 | var node = Node.new() 14 | 15 | # NOTE: I found this test is biased, and I can't do anything about it. 16 | # Godot appears to run it slower if there are more iterations. 17 | # Adding and removing nodes has a race condition over the time it takes. 18 | 19 | for i in range(0, ITERATIONS): 20 | root.add_child(node) 21 | root.remove_child(node) 22 | 23 | node.free() 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /project31/tests/test_constants_addition.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add two constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | 8 | func execute(): 9 | for i in range(0,ITERATIONS): 10 | var x = CONST01 + CONST02 11 | -------------------------------------------------------------------------------- /project31/tests/test_constants_addition_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | const CONST03 = 0 8 | const CONST04 = 0 9 | const CONST05 = 0 10 | const CONST06 = 0 11 | const CONST07 = 0 12 | const CONST08 = 0 13 | const CONST09 = 0 14 | const CONST10 = 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project31/tests/test_constants_addition_x10_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants (typed)" 4 | 5 | const CONST01 := 0 6 | const CONST02 := 0 7 | const CONST03 := 0 8 | const CONST04 := 0 9 | const CONST05 := 0 10 | const CONST06 := 0 11 | const CONST07 := 0 12 | const CONST08 := 0 13 | const CONST09 := 0 14 | const CONST10 := 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x : int = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project31/tests/test_deep_transform_3d_get.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var parent = tree_root 11 | 12 | for d in 10: 13 | var child = Spatial.new() 14 | child.set_name("Spatial") 15 | parent.add_child(child) 16 | _leaf_spatial = child 17 | parent = child 18 | 19 | _root_spatial = tree_root.get_node("Spatial") 20 | 21 | 22 | func execute(): 23 | var root = _root_spatial 24 | var leaf = _leaf_spatial 25 | 26 | var t1 = Transform(Basis(), Vector3(1, 2, 3)) 27 | var t2 = Transform(Basis().rotated(Vector3(0, 1, 0), 33), Vector3()) 28 | 29 | var iterations = ITERATIONS / 2 30 | 31 | for i in range(0, iterations): 32 | root.set_transform(t1) 33 | leaf.get_global_transform() 34 | root.set_transform(t2) 35 | leaf.get_global_transform() 36 | -------------------------------------------------------------------------------- /project31/tests/test_deep_transform_3d_noget.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change without querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var root = tree_root 11 | for d in 10: 12 | var s = Spatial.new() 13 | s.set_name("Spatial") 14 | root.add_child(s) 15 | root = s 16 | _leaf_spatial = s 17 | _root_spatial = tree_root.get_node("Spatial") 18 | 19 | 20 | func execute(): 21 | var root = _root_spatial 22 | 23 | var t1 = Transform(Basis(), Vector3(1, 2, 3)) 24 | var t2 = Transform(Basis().rotated(Vector3(0, 1, 0), 33), Vector3()) 25 | 26 | var iterations = ITERATIONS / 2 27 | 28 | for i in range(0, iterations): 29 | root.set_transform(t1) 30 | root.set_transform(t2) 31 | -------------------------------------------------------------------------------- /project31/tests/test_divide.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide" 4 | 5 | func execute(): 6 | var a = 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project31/tests/test_divide_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide (typed)" 4 | 5 | func execute(): 6 | var a := 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project31/tests/test_emit_signal.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal" 4 | 5 | signal test_signal 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal") 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_emit_signal_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal with very long name" 4 | 5 | signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_empty_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Empty func (void function call cost)" 5 | 6 | 7 | func execute(): 8 | for i in range(0,ITERATIONS): 9 | empty_func() 10 | 11 | 12 | func empty_func(): 13 | pass 14 | 15 | -------------------------------------------------------------------------------- /project31/tests/test_engine_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func getter" 5 | 6 | 7 | func execute(): 8 | var obj = Node.new() 9 | for i in range(0,ITERATIONS): 10 | obj.get_index() 11 | obj.free() 12 | 13 | -------------------------------------------------------------------------------- /project31/tests/test_engine_func_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func getter (typed)" 5 | 6 | 7 | func execute(): 8 | var obj := Node.new() 9 | for i in range(0,ITERATIONS): 10 | obj.get_index() 11 | obj.free() 12 | 13 | -------------------------------------------------------------------------------- /project31/tests/test_engine_func_with_params.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func with params (str, bool, bool)" 5 | 6 | 7 | func execute(): 8 | var obj = Node.new() 9 | 10 | var a = "" 11 | var b = false 12 | var c = false 13 | 14 | # Function was chosen for almost doing nothing C++ side 15 | for i in range(0,ITERATIONS): 16 | obj.find_node(a, b, c) 17 | 18 | obj.free() 19 | 20 | -------------------------------------------------------------------------------- /project31/tests/test_engine_func_with_params_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func with params (str, bool, bool) (typed)" 5 | 6 | 7 | func execute(): 8 | var obj := Node.new() 9 | 10 | var a := "" 11 | var b := false 12 | var c := false 13 | 14 | # Function was chosen for almost doing nothing C++ side 15 | for i in range(0,ITERATIONS): 16 | obj.find_node(a, b, c) 17 | 18 | obj.free() 19 | 20 | -------------------------------------------------------------------------------- /project31/tests/test_for_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "For time (one very long for)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | for i in range(0, ITERATIONS): 12 | pass 13 | -------------------------------------------------------------------------------- /project31/tests/test_func_with_params.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func.gd` 4 | var description = "Call script class func(str, bool, bool)" 5 | 6 | class TestObj: 7 | func foo(a, b, c): 8 | pass 9 | 10 | 11 | func execute(): 12 | var obj = TestObj.new() 13 | 14 | var a = "" 15 | var b = false 16 | var c = false 17 | 18 | for i in range(0,ITERATIONS): 19 | obj.foo(a, b, c) 20 | 21 | 22 | -------------------------------------------------------------------------------- /project31/tests/test_func_with_params_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func_typed.gd` 4 | var description = "Call script class func(str, bool, bool) (typed)" 5 | 6 | class TestObj: 7 | func foo(a: String, b: bool, c: bool): 8 | pass 9 | 10 | 11 | func execute(): 12 | var obj = TestObj.new() 13 | 14 | var a := "" 15 | var b := false 16 | var c := false 17 | 18 | for i in range(0,ITERATIONS): 19 | obj.foo(a, b, c) 20 | 21 | -------------------------------------------------------------------------------- /project31/tests/test_get_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where only one child" 4 | 5 | 6 | func setup(): 7 | var node = Node.new() 8 | node.set_name("GetNodeTest") 9 | tree_root.add_child(node) 10 | 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | tree_root.get_node("GetNodeTest") 15 | -------------------------------------------------------------------------------- /project31/tests/test_get_node_10_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where 10 children" 4 | 5 | 6 | func setup(): 7 | for i in 10: 8 | var n = Node.new() 9 | n.set_name("GetNodeTest_" + str(i)) 10 | tree_root.add_child(n) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node("GetNodeTest_9") 16 | -------------------------------------------------------------------------------- /project31/tests/test_get_node_10_children_3_deep.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() 3 parents deep having 10 children" 4 | 5 | 6 | func setup(): 7 | var root = tree_root 8 | for d in 3: 9 | for i in 10: 10 | var n = Node.new() 11 | n.set_name("GetNodeTest_" + str(i)) 12 | root.add_child(n) 13 | root = root.get_node("GetNodeTest_9") 14 | 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | tree_root.get_node("GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 19 | -------------------------------------------------------------------------------- /project31/tests/test_if_true.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true) time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | 10 | -------------------------------------------------------------------------------- /project31/tests/test_if_true_else.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true)else time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | else: 10 | pass 11 | -------------------------------------------------------------------------------- /project31/tests/test_increment.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project31/tests/test_increment_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (typed)" 4 | 5 | func execute(): 6 | var a := 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project31/tests/test_increment_vector2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector2" 4 | 5 | func execute(): 6 | var a = Vector2(0,0) 7 | var b = Vector2(1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_increment_vector3.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3" 4 | 5 | 6 | func execute(): 7 | var a = Vector3(0,0,0) 8 | var b = Vector3(1,1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += b 12 | -------------------------------------------------------------------------------- /project31/tests/test_increment_vector3_constant.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Increment Vector3 with constant" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += Vector3(1,1,1) 12 | -------------------------------------------------------------------------------- /project31/tests/test_increment_vector3_individual_xyz.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3 coordinate by coordinate" 4 | 5 | func execute(): 6 | var a = Vector3(0,0,0) 7 | var b = Vector3(1,1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a.x += b.x 11 | a.y += b.y 12 | a.z += b.z 13 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_array_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with array member" 4 | 5 | func execute(): 6 | var a = 0 7 | var arr = [1] 8 | for i in range(0, ITERATIONS): 9 | a += arr[0] 10 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_class_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member" 4 | 5 | class TestClassForMemberAccess: 6 | var x = 0 7 | 8 | func execute(): 9 | var a = 0 10 | var c = TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_class_member_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member (typed)" 4 | 5 | class TestClassForMemberAccess: 6 | var x := 0 7 | 8 | func execute(): 9 | var a := 0 10 | var c := TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_dictionary_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with dictionary member" 4 | 5 | 6 | func execute(): 7 | var a = 0 8 | var dic = {b = 1} 9 | for i in range(0,ITERATIONS): 10 | a += dic.b 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_local_inside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (inside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | 8 | for i in range(0, ITERATIONS): 9 | var b = 1 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_local_outside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (outside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | var b = 1 8 | 9 | for i in range(0,ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_member_var.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += _test_a 12 | 13 | -------------------------------------------------------------------------------- /project31/tests/test_increment_with_member_var_using_self.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var using self" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += self._test_a 12 | 13 | -------------------------------------------------------------------------------- /project31/tests/test_increment_x5.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5)" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project31/tests/test_increment_x5_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5) (typed)" 4 | 5 | func execute(): 6 | var a := 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project31/tests/test_int_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray set element" 4 | 5 | func execute(): 6 | var i_array = PoolIntArray() 7 | i_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | i_array[42] = 0 11 | -------------------------------------------------------------------------------- /project31/tests/test_int_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = PoolIntArray() 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project31/tests/test_int_to_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String str(i)" 4 | 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | str(i) 9 | 10 | -------------------------------------------------------------------------------- /project31/tests/test_just_comments.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Just 20 lines of comments (should take zero time on release build)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | # Comment 1 8 | # Comment 2 9 | # Comment 3 10 | # Comment 4 11 | # Comment 5 12 | # Comment 6 13 | # Comment 7 14 | # Comment 8 15 | # Comment 9 16 | # Comment 10 17 | # Comment 11 18 | # Comment 12 19 | # Comment 13 20 | # Comment 14 21 | # Comment 15 22 | # Comment 16 23 | # Comment 17 24 | # Comment 18 25 | # Comment 19 26 | # Comment 20 27 | pass 28 | 29 | -------------------------------------------------------------------------------- /project31/tests/test_load.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of load() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = load("res://tests/test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | load("res://tests/test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_new_class.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (no member variables)" 4 | 5 | 6 | class TestClass1: 7 | func foo(): 8 | pass 9 | 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass1.new() 14 | -------------------------------------------------------------------------------- /project31/tests/test_new_class_with_10_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (10 member variables)" 4 | 5 | class TestClass10: 6 | var v0 = 0 7 | var v1 = 0 8 | var v2 = 0 9 | var v3 = 0 10 | var v4 = 0 11 | var v5 = 0 12 | var v6 = 0 13 | var v7 = 0 14 | var v8 = 0 15 | var v9 = 0 16 | func foo(): 17 | pass 18 | 19 | func execute(): 20 | for i in range(0, ITERATIONS): 21 | TestClass10.new() 22 | -------------------------------------------------------------------------------- /project31/tests/test_new_class_with_2_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (2 member variables)" 4 | 5 | class TestClass2: 6 | var x = 0 7 | var y = 0 8 | func foo(): 9 | pass 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass2.new() 14 | -------------------------------------------------------------------------------- /project31/tests/test_new_class_with_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class with long name (no member variables)" 4 | 5 | class TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName: 6 | func foo(): 7 | pass 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName.new() 12 | 13 | -------------------------------------------------------------------------------- /project31/tests/test_preload.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of preload() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = preload("test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | preload("test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project31/tests/test_string_concat.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 1 number" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc" + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project31/tests/test_string_concat_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers" 4 | 5 | 6 | func setup(): 7 | # That test is quite long 8 | ITERATIONS /= 2 9 | 10 | 11 | func execute(): 12 | var a = 42 13 | for i in range(0, ITERATIONS): 14 | "abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a)+ " abc " + str(a) + " abc " + str(a) 15 | 16 | -------------------------------------------------------------------------------- /project31/tests/test_string_concat_x10_str_vararg.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers str vararg" 4 | 5 | 6 | func setup(): 7 | # That test is quite long 8 | ITERATIONS /= 2 9 | 10 | 11 | func execute(): 12 | var a = 42 13 | for i in range(0, ITERATIONS): 14 | str("abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a)) 15 | 16 | -------------------------------------------------------------------------------- /project31/tests/test_string_format.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String format with 1 number" 4 | 5 | func can_run(context): 6 | var v = context.engine_version.major 7 | return v != "1" and v != "2" 8 | 9 | 10 | func execute(): 11 | var a = 42 12 | for i in range(0, ITERATIONS): 13 | "abc {0}".format([a]) 14 | -------------------------------------------------------------------------------- /project31/tests/test_string_format_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String format with 10 numbers" 4 | 5 | func can_run(context): 6 | var v = context.engine_version.major 7 | return v != "1" and v != "2" 8 | 9 | 10 | func setup(): 11 | # This test takes long 12 | ITERATIONS /= 5 13 | 14 | 15 | func execute(): 16 | var a = 42 17 | for i in range(0, ITERATIONS): 18 | "abc {0} abc {1} abc {2} abc {3} abc {4} abc {5} abc {6} abc {7} abc {8} abc {9}".format([a,a,a,a,a,a,a,a,a,a]) 19 | -------------------------------------------------------------------------------- /project31/tests/test_unused_local.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Unused local (declaration cost)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var b = 1 8 | -------------------------------------------------------------------------------- /project31/tests/test_variant_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray set element" 4 | 5 | func execute(): 6 | var v_array = [] 7 | v_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | v_array[42] = 0 11 | -------------------------------------------------------------------------------- /project31/tests/test_variant_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = [] 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project31/tests/test_while_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "While time (one very long while)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | var i = 0 12 | while i < ITERATIONS: 13 | i += 1 14 | -------------------------------------------------------------------------------- /project32/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project32/icon.png -------------------------------------------------------------------------------- /project32/icon.png.flags: -------------------------------------------------------------------------------- 1 | gen_mipmaps=false 2 | -------------------------------------------------------------------------------- /project32/icon.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://icon.png" 13 | dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=true 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /project32/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://start.gd" type="Script" id=1] 4 | 5 | [node name="Node" type="Node"] 6 | script = ExtResource( 1 ) 7 | 8 | -------------------------------------------------------------------------------- /project32/polyfills.gd: -------------------------------------------------------------------------------- 1 | # This test suite should be useable on many Godot versions, 2 | # because one goal of this test suite is to be able to compare them 3 | 4 | 5 | static func is_instance_of(a, klass): 6 | return a is klass 7 | 8 | 9 | static func get_time_msec(): 10 | return OS.get_ticks_msec() 11 | 12 | 13 | static func is_debug_build(): 14 | return OS.is_debug_build() 15 | 16 | 17 | static func get_extension(s): 18 | return s.get_extension() 19 | 20 | 21 | static func convert_to_json(d): 22 | return to_json(d) 23 | -------------------------------------------------------------------------------- /project32/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=4 10 | 11 | _global_script_classes=[ ] 12 | _global_script_class_icons={ 13 | 14 | } 15 | 16 | [application] 17 | 18 | config/name="Nouveau projet de jeu" 19 | run/main_scene="res://main.tscn" 20 | config/icon="res://icon.png" 21 | 22 | [gdnative] 23 | 24 | singletons=[ ] 25 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/bunnymark/bunny.gd: -------------------------------------------------------------------------------- 1 | extends Sprite 2 | 3 | 4 | var vx = randi() % 200 + 50 5 | var vy = randi() % 200 + 50 6 | var ay = 980 7 | 8 | 9 | func _ready(): 10 | set_position(Vector2(50, 50)) 11 | set_process(true) 12 | 13 | 14 | func _process(delta): 15 | var pos = get_position() 16 | 17 | pos.x = pos.x + vx * delta 18 | pos.y = pos.y + vy * delta 19 | 20 | vy = vy + ay * delta 21 | 22 | if pos.x > 800: 23 | vx = -vx 24 | pos.x = 800 25 | 26 | if pos.x < 0: 27 | vx = abs(vx) 28 | pos.x = 0 29 | 30 | if pos.y > 600: 31 | vy = -0.85 * vy 32 | pos.y = 600 33 | if randf() > 0.5: 34 | vy = -(randi() % 1100 + 50) 35 | 36 | if pos.y < 0: 37 | vy = 0 38 | pos.y = 0 39 | 40 | set_position(pos) 41 | 42 | 43 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/bunnymark/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project32/scale_benchmarks/bunnymark/bunny.png -------------------------------------------------------------------------------- /project32/scale_benchmarks/bunnymark/bunny.png.import: -------------------------------------------------------------------------------- 1 | [remap] 2 | 3 | importer="texture" 4 | type="StreamTexture" 5 | path="res://.import/bunny.png-b9bb18bcf5e2838b2b16bd5993c7957e.stex" 6 | metadata={ 7 | "vram_texture": false 8 | } 9 | 10 | [deps] 11 | 12 | source_file="res://scale_benchmarks/bunnymark/bunny.png" 13 | dest_files=[ "res://.import/bunny.png-b9bb18bcf5e2838b2b16bd5993c7957e.stex" ] 14 | 15 | [params] 16 | 17 | compress/mode=0 18 | compress/lossy_quality=0.7 19 | compress/hdr_mode=0 20 | compress/bptc_ldr=0 21 | compress/normal_map=0 22 | flags/repeat=0 23 | flags/filter=false 24 | flags/mipmaps=false 25 | flags/anisotropic=false 26 | flags/srgb=2 27 | process/fix_alpha_border=true 28 | process/premult_alpha=false 29 | process/HDR_as_SRGB=false 30 | process/invert_color=false 31 | stream=false 32 | size_limit=0 33 | detect_3d=true 34 | svg/scale=1.0 35 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/bunnymark/bunny.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.png" type="Texture" id=1] 4 | [ext_resource path="res://scale_benchmarks/bunnymark/bunny.gd" type="Script" id=2] 5 | 6 | [node name="Bunny" type="Sprite" index="0"] 7 | 8 | texture = ExtResource( 1 ) 9 | script = ExtResource( 2 ) 10 | 11 | 12 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/bunnymark/bunnymark.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Bunnymark" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of bunnies" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | for i in range(0, 10): 18 | var bunny_scene = load("res://scale_benchmarks/bunnymark/bunny.tscn") 19 | var bunny = bunny_scene.instance() 20 | add_child(bunny) 21 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/bunnymark/bunnymark.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/bunnymark/bunnymark.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node"] 7 | script = ExtResource( 1 ) 8 | 9 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/cube_spam/cube_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/cube_spam_blank_environment/cube_spam_blank_environment.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/cube_spam_with_shadows/cube_spam_with_shadows.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = CubeMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance.new() 19 | mi.mesh = mesh 20 | mi.set_translation(Vector3(rand_range(-10, 10), rand_range(-10, 10), rand_range(-10, 10))) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/node_spam_with_process/node_spam_with_process.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Nodes with empty process function" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of processing nodes" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var processor_scene = load("res://scale_benchmarks/node_spam_with_process/processor.gd") 18 | for i in range(0, 1000): 19 | var processor = processor_scene.new() 20 | add_child(processor) 21 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/node_spam_with_process/node_spam_with_process.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/node_spam_with_process/node_spam_with_process.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/node_spam_with_process/processor.gd: -------------------------------------------------------------------------------- 1 | extends Node 2 | 3 | 4 | func _ready(): 5 | set_process(true) 6 | 7 | 8 | func _process(delta): 9 | pass 10 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/physics_spheres/physics_spheres.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming spheres with physics" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of spheres" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() - 7 14 | 15 | 16 | func process(delta): 17 | var scene = load("res://scale_benchmarks/physics_spheres/sphere_body.tscn") 18 | for i in range(0, 1): 19 | var s = scene.instance() 20 | s.set_translation(Vector3(rand_range(-1, 1), 50, rand_range(-1, 1))) 21 | add_child(s) 22 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/physics_spheres/sphere_body.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=2] 2 | 3 | [sub_resource type="SphereShape" id=1] 4 | 5 | 6 | [sub_resource type="SphereMesh" id=2] 7 | 8 | radial_segments = 8 9 | rings = 4 10 | 11 | [node name="SphereBody" type="RigidBody"] 12 | 13 | [node name="CollisionShape" type="CollisionShape" parent="."] 14 | shape = SubResource( 1 ) 15 | 16 | [node name="MeshInstance" type="MeshInstance" parent="."] 17 | visible = false 18 | mesh = SubResource( 2 ) 19 | material/0 = null 20 | 21 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/sprite_spam/sprite_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming sprites" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of sprites" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var tex = load("res://icon.png") 18 | for i in range(0, 100): 19 | var sprite = Sprite.new() 20 | sprite.set_texture(tex) 21 | sprite.set_position(Vector2(rand_range(100, 400), rand_range(100, 400))) 22 | add_child(sprite) 23 | -------------------------------------------------------------------------------- /project32/scale_benchmarks/sprite_spam/sprite_spam.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=2] 2 | 3 | [ext_resource path="res://scale_benchmarks/sprite_spam/sprite_spam.gd" type="Script" id=1] 4 | 5 | 6 | [node name="Node" type="Node" index="0"] 7 | 8 | script = ExtResource( 1 ) 9 | 10 | 11 | -------------------------------------------------------------------------------- /project32/start.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Node 3 | 4 | func _ready(): 5 | var s = load("res://test_singleton.gd").new() 6 | add_child(s) 7 | s.begin_tests() 8 | get_tree().quit() 9 | 10 | 11 | -------------------------------------------------------------------------------- /project32/tests/test.gd: -------------------------------------------------------------------------------- 1 | 2 | # Set by the main test script 3 | var ITERATIONS = null 4 | var tree_root = null 5 | 6 | # var description = "Test base class" 7 | 8 | func can_run(context): 9 | return true 10 | 11 | 12 | func should_subtract_loop_duration(): 13 | return true 14 | 15 | 16 | func setup(): 17 | pass 18 | 19 | 20 | func execute(): 21 | pass 22 | 23 | -------------------------------------------------------------------------------- /project32/tests/test_add_remove_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add and remove node" 4 | 5 | 6 | func setup(): 7 | ITERATIONS /= 50 8 | 9 | 10 | func execute(): 11 | 12 | var root = tree_root 13 | var node = Node.new() 14 | 15 | # NOTE: I found this test is biased, and I can't do anything about it. 16 | # Godot appears to run it slower if there are more iterations. 17 | # Adding and removing nodes has a race condition over the time it takes. 18 | 19 | for i in range(0, ITERATIONS): 20 | root.add_child(node) 21 | root.remove_child(node) 22 | 23 | node.free() 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /project32/tests/test_constants_addition.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add two constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | 8 | func execute(): 9 | for i in range(0,ITERATIONS): 10 | var x = CONST01 + CONST02 11 | -------------------------------------------------------------------------------- /project32/tests/test_constants_addition_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants" 4 | 5 | const CONST01 = 0 6 | const CONST02 = 0 7 | const CONST03 = 0 8 | const CONST04 = 0 9 | const CONST05 = 0 10 | const CONST06 = 0 11 | const CONST07 = 0 12 | const CONST08 = 0 13 | const CONST09 = 0 14 | const CONST10 = 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project32/tests/test_constants_addition_x10_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Add 10 constants (typed)" 4 | 5 | const CONST01 := 0 6 | const CONST02 := 0 7 | const CONST03 := 0 8 | const CONST04 := 0 9 | const CONST05 := 0 10 | const CONST06 := 0 11 | const CONST07 := 0 12 | const CONST08 := 0 13 | const CONST09 := 0 14 | const CONST10 := 0 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | var x : int = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 19 | -------------------------------------------------------------------------------- /project32/tests/test_deep_transform_3d_noget.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Deep transform change without querying leaf" 4 | 5 | var _root_spatial = null 6 | var _leaf_spatial = null 7 | 8 | 9 | func setup(): 10 | var root = tree_root 11 | for d in 10: 12 | var s = Spatial.new() 13 | s.set_name("Spatial") 14 | root.add_child(s) 15 | root = s 16 | _leaf_spatial = s 17 | _root_spatial = tree_root.get_node("Spatial") 18 | 19 | 20 | func execute(): 21 | var root = _root_spatial 22 | 23 | var t1 = Transform(Basis(), Vector3(1, 2, 3)) 24 | var t2 = Transform(Basis().rotated(Vector3(0, 1, 0), 33), Vector3()) 25 | 26 | var iterations = ITERATIONS / 2 27 | 28 | for i in range(0, iterations): 29 | root.set_transform(t1) 30 | root.set_transform(t2) 31 | -------------------------------------------------------------------------------- /project32/tests/test_divide.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide" 4 | 5 | func execute(): 6 | var a = 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project32/tests/test_divide_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Divide (typed)" 4 | 5 | func execute(): 6 | var a := 9999 7 | for i in range(0, ITERATIONS): 8 | a /= 2 9 | -------------------------------------------------------------------------------- /project32/tests/test_emit_signal.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal" 4 | 5 | signal test_signal 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal") 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_emit_signal_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Emit not-connected signal with very long name" 4 | 5 | signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 6 | 7 | 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | emit_signal("test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_empty_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Empty func (void function call cost)" 5 | 6 | 7 | func execute(): 8 | for i in range(0,ITERATIONS): 9 | empty_func() 10 | 11 | 12 | func empty_func(): 13 | pass 14 | 15 | -------------------------------------------------------------------------------- /project32/tests/test_engine_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func getter" 5 | 6 | 7 | func execute(): 8 | var obj = Node.new() 9 | for i in range(0,ITERATIONS): 10 | obj.get_index() 11 | obj.free() 12 | 13 | -------------------------------------------------------------------------------- /project32/tests/test_engine_func_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func getter (typed)" 5 | 6 | 7 | func execute(): 8 | var obj := Node.new() 9 | for i in range(0,ITERATIONS): 10 | obj.get_index() 11 | obj.free() 12 | 13 | -------------------------------------------------------------------------------- /project32/tests/test_engine_func_with_params.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func with params (str, bool, bool)" 5 | 6 | 7 | func execute(): 8 | var obj = Node.new() 9 | 10 | var a = "" 11 | var b = false 12 | var c = false 13 | 14 | # Function was chosen for almost doing nothing C++ side 15 | for i in range(0,ITERATIONS): 16 | obj.find_node(a, b, c) 17 | 18 | obj.free() 19 | 20 | -------------------------------------------------------------------------------- /project32/tests/test_engine_func_with_params_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Call engine func with params (str, bool, bool) (typed)" 5 | 6 | 7 | func execute(): 8 | var obj := Node.new() 9 | 10 | var a := "" 11 | var b := false 12 | var c := false 13 | 14 | # Function was chosen for almost doing nothing C++ side 15 | for i in range(0,ITERATIONS): 16 | obj.find_node(a, b, c) 17 | 18 | obj.free() 19 | 20 | -------------------------------------------------------------------------------- /project32/tests/test_for_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "For time (one very long for)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | for i in range(0, ITERATIONS): 12 | pass 13 | -------------------------------------------------------------------------------- /project32/tests/test_func_with_params.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func.gd` 4 | var description = "Call script class func(str, bool, bool)" 5 | 6 | class TestObj: 7 | func foo(a, b, c): 8 | pass 9 | 10 | 11 | func execute(): 12 | var obj = TestObj.new() 13 | 14 | var a = "" 15 | var b = false 16 | var c = false 17 | 18 | for i in range(0,ITERATIONS): 19 | obj.foo(a, b, c) 20 | 21 | 22 | -------------------------------------------------------------------------------- /project32/tests/test_func_with_params_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func_typed.gd` 4 | var description = "Call script class func(str, bool, bool) (typed)" 5 | 6 | class TestObj: 7 | func foo(a: String, b: bool, c: bool): 8 | pass 9 | 10 | 11 | func execute(): 12 | var obj = TestObj.new() 13 | 14 | var a := "" 15 | var b := false 16 | var c := false 17 | 18 | for i in range(0,ITERATIONS): 19 | obj.foo(a, b, c) 20 | 21 | -------------------------------------------------------------------------------- /project32/tests/test_get_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where only one child" 4 | 5 | 6 | func setup(): 7 | var node = Node.new() 8 | node.set_name("GetNodeTest") 9 | tree_root.add_child(node) 10 | 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | tree_root.get_node("GetNodeTest") 15 | -------------------------------------------------------------------------------- /project32/tests/test_get_node_10_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() where 10 children" 4 | 5 | 6 | func setup(): 7 | for i in 10: 8 | var n = Node.new() 9 | n.set_name("GetNodeTest_" + str(i)) 10 | tree_root.add_child(n) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node("GetNodeTest_9") 16 | -------------------------------------------------------------------------------- /project32/tests/test_get_node_10_children_3_deep.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() 3 parents deep having 10 children" 4 | 5 | 6 | func setup(): 7 | var root = tree_root 8 | for d in 3: 9 | for i in 10: 10 | var n = Node.new() 11 | n.set_name("GetNodeTest_" + str(i)) 12 | root.add_child(n) 13 | root = root.get_node("GetNodeTest_9") 14 | 15 | 16 | func execute(): 17 | for i in range(0, ITERATIONS): 18 | tree_root.get_node("GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 19 | -------------------------------------------------------------------------------- /project32/tests/test_get_node_10_children_3_deep_dollar.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "get_node() 3 parents deep having 10 children with $" 4 | 5 | # `$` is reserved to classes extending `Node`, but `test.gd` doesn't extend that 6 | class MyNode extends Node: 7 | var ITERATIONS 8 | func execute(): 9 | for i in range(0, ITERATIONS): 10 | $GetNodeTest_9/GetNodeTest_9/GetNodeTest_9 11 | 12 | var _my_node 13 | 14 | func setup(): 15 | var root = tree_root 16 | _my_node = MyNode.new() 17 | _my_node.ITERATIONS = ITERATIONS 18 | root.add_child(_my_node) 19 | root = _my_node 20 | for d in 3: 21 | for i in 10: 22 | var n = Node.new() 23 | n.set_name("GetNodeTest_" + str(i)) 24 | root.add_child(n) 25 | root = root.get_node("GetNodeTest_9") 26 | 27 | 28 | func execute(): 29 | _my_node.execute() 30 | -------------------------------------------------------------------------------- /project32/tests/test_if_true.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true) time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | 10 | -------------------------------------------------------------------------------- /project32/tests/test_if_true_else.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "if(true)else time" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | if true: 8 | pass 9 | else: 10 | pass 11 | -------------------------------------------------------------------------------- /project32/tests/test_image_get_pixel.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Image get pixel" 4 | 5 | 6 | func execute(): 7 | var im = Image.new() 8 | im.create(512, 512, false, Image.FORMAT_RGB8) 9 | 10 | im.lock() 11 | 12 | for i in range(0, ITERATIONS): 13 | im.get_pixel(42, 84) 14 | 15 | im.unlock() 16 | 17 | -------------------------------------------------------------------------------- /project32/tests/test_image_set_pixel.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Image set pixel" 4 | 5 | 6 | func execute(): 7 | var im = Image.new() 8 | im.create(512, 512, false, Image.FORMAT_RGB8) 9 | 10 | im.lock() 11 | 12 | for i in range(0, ITERATIONS): 13 | im.set_pixel(42, 84, Color(0.0, 0.0, 0.0)) 14 | 15 | im.unlock() 16 | 17 | -------------------------------------------------------------------------------- /project32/tests/test_increment.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project32/tests/test_increment_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (typed)" 4 | 5 | func execute(): 6 | var a := 0 7 | for i in range(0, ITERATIONS): 8 | a += 1 9 | 10 | -------------------------------------------------------------------------------- /project32/tests/test_increment_vector2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector2" 4 | 5 | func execute(): 6 | var a = Vector2(0,0) 7 | var b = Vector2(1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_increment_vector3.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3" 4 | 5 | 6 | func execute(): 7 | var a = Vector3(0,0,0) 8 | var b = Vector3(1,1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += b 12 | -------------------------------------------------------------------------------- /project32/tests/test_increment_vector3_constant.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | var description = "Increment Vector3 with constant" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += Vector3(1,1,1) 12 | -------------------------------------------------------------------------------- /project32/tests/test_increment_vector3_individual_xyz.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment Vector3 coordinate by coordinate" 4 | 5 | func execute(): 6 | var a = Vector3(0,0,0) 7 | var b = Vector3(1,1,1) 8 | 9 | for i in range(0, ITERATIONS): 10 | a.x += b.x 11 | a.y += b.y 12 | a.z += b.z 13 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_array_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with array member" 4 | 5 | func execute(): 6 | var a = 0 7 | var arr = [1] 8 | for i in range(0, ITERATIONS): 9 | a += arr[0] 10 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_class_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member" 4 | 5 | class TestClassForMemberAccess: 6 | var x = 0 7 | 8 | func execute(): 9 | var a = 0 10 | var c = TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_class_member_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with class member (typed)" 4 | 5 | class TestClassForMemberAccess: 6 | var x := 0 7 | 8 | func execute(): 9 | var a := 0 10 | var c := TestClassForMemberAccess.new() 11 | for i in range(0, ITERATIONS): 12 | a += c.x 13 | 14 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_dictionary_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with dictionary member" 4 | 5 | 6 | func execute(): 7 | var a = 0 8 | var dic = {b = 1} 9 | for i in range(0,ITERATIONS): 10 | a += dic.b 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_local_inside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (inside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | 8 | for i in range(0, ITERATIONS): 9 | var b = 1 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_local_outside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with local (outside loop)" 4 | 5 | func execute(): 6 | var a = 0 7 | var b = 1 8 | 9 | for i in range(0,ITERATIONS): 10 | a += b 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_member_var.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += _test_a 12 | 13 | -------------------------------------------------------------------------------- /project32/tests/test_increment_with_member_var_using_self.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment with member var using self" 4 | 5 | var _test_a = 0 6 | 7 | 8 | func execute(): 9 | var a = 0 10 | for i in range(0,ITERATIONS): 11 | a += self._test_a 12 | 13 | -------------------------------------------------------------------------------- /project32/tests/test_increment_x5.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5)" 4 | 5 | func execute(): 6 | var a = 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project32/tests/test_increment_x5_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Increment (x5) (typed)" 4 | 5 | func execute(): 6 | var a := 0 7 | for i in range(0,ITERATIONS): 8 | a += 1 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | -------------------------------------------------------------------------------- /project32/tests/test_int_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray set element" 4 | 5 | func execute(): 6 | var i_array = PoolIntArray() 7 | i_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | i_array[42] = 0 11 | -------------------------------------------------------------------------------- /project32/tests/test_int_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "IntArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = PoolIntArray() 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project32/tests/test_int_to_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String str(i)" 4 | 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | str(i) 9 | 10 | -------------------------------------------------------------------------------- /project32/tests/test_just_comments.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Just 20 lines of comments (should take zero time on release build)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | # Comment 1 8 | # Comment 2 9 | # Comment 3 10 | # Comment 4 11 | # Comment 5 12 | # Comment 6 13 | # Comment 7 14 | # Comment 8 15 | # Comment 9 16 | # Comment 10 17 | # Comment 11 18 | # Comment 12 19 | # Comment 13 20 | # Comment 14 21 | # Comment 15 22 | # Comment 16 23 | # Comment 17 24 | # Comment 18 25 | # Comment 19 26 | # Comment 20 27 | pass 28 | 29 | -------------------------------------------------------------------------------- /project32/tests/test_load.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of load() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = load("res://tests/test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | load("res://tests/test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_new_class.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (no member variables)" 4 | 5 | 6 | class TestClass1: 7 | func foo(): 8 | pass 9 | 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass1.new() 14 | -------------------------------------------------------------------------------- /project32/tests/test_new_class_with_10_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (10 member variables)" 4 | 5 | class TestClass10: 6 | var v0 = 0 7 | var v1 = 0 8 | var v2 = 0 9 | var v3 = 0 10 | var v4 = 0 11 | var v5 = 0 12 | var v6 = 0 13 | var v7 = 0 14 | var v8 = 0 15 | var v9 = 0 16 | func foo(): 17 | pass 18 | 19 | func execute(): 20 | for i in range(0, ITERATIONS): 21 | TestClass10.new() 22 | -------------------------------------------------------------------------------- /project32/tests/test_new_class_with_2_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class (2 member variables)" 4 | 5 | class TestClass2: 6 | var x = 0 7 | var y = 0 8 | func foo(): 9 | pass 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | TestClass2.new() 14 | -------------------------------------------------------------------------------- /project32/tests/test_new_class_with_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Instance class with long name (no member variables)" 4 | 5 | class TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName: 6 | func foo(): 7 | pass 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName.new() 12 | 13 | -------------------------------------------------------------------------------- /project32/tests/test_preload.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Cost of preload() (regardless of resource)" 4 | 5 | func execute(): 6 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 7 | var res = preload("test.gd") 8 | 9 | for i in range(0, ITERATIONS): 10 | preload("test.gd") 11 | 12 | -------------------------------------------------------------------------------- /project32/tests/test_string_concat.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 1 number" 4 | 5 | 6 | func execute(): 7 | var a = 42 8 | for i in range(0, ITERATIONS): 9 | "abc" + str(a) 10 | 11 | -------------------------------------------------------------------------------- /project32/tests/test_string_concat_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers" 4 | 5 | 6 | func setup(): 7 | # That test is quite long 8 | ITERATIONS /= 2 9 | 10 | 11 | func execute(): 12 | var a = 42 13 | for i in range(0, ITERATIONS): 14 | "abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a)+ " abc " + str(a) + " abc " + str(a) 15 | 16 | -------------------------------------------------------------------------------- /project32/tests/test_string_concat_x10_str_vararg.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String concat with 10 numbers str vararg" 4 | 5 | 6 | func setup(): 7 | # That test is quite long 8 | ITERATIONS /= 2 9 | 10 | 11 | func execute(): 12 | var a = 42 13 | for i in range(0, ITERATIONS): 14 | str("abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a)) 15 | 16 | -------------------------------------------------------------------------------- /project32/tests/test_string_format.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String format with 1 number" 4 | 5 | func can_run(context): 6 | var v = context.engine_version.major 7 | return v != "1" and v != "2" 8 | 9 | 10 | func execute(): 11 | var a = 42 12 | for i in range(0, ITERATIONS): 13 | "abc {0}".format([a]) 14 | -------------------------------------------------------------------------------- /project32/tests/test_string_format_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "String format with 10 numbers" 4 | 5 | func can_run(context): 6 | var v = context.engine_version.major 7 | return v != "1" and v != "2" 8 | 9 | 10 | func setup(): 11 | # This test takes long 12 | ITERATIONS /= 5 13 | 14 | 15 | func execute(): 16 | var a = 42 17 | for i in range(0, ITERATIONS): 18 | "abc {0} abc {1} abc {2} abc {3} abc {4} abc {5} abc {6} abc {7} abc {8} abc {9}".format([a,a,a,a,a,a,a,a,a,a]) 19 | -------------------------------------------------------------------------------- /project32/tests/test_unused_local.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "Unused local (declaration cost)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var b = 1 8 | -------------------------------------------------------------------------------- /project32/tests/test_variant_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray set element" 4 | 5 | func execute(): 6 | var v_array = [] 7 | v_array.resize(100) 8 | 9 | for i in range(0, ITERATIONS): 10 | v_array[42] = 0 11 | -------------------------------------------------------------------------------- /project32/tests/test_variant_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "VariantArray resize(1000)" 4 | 5 | func execute(): 6 | for i in range(0, ITERATIONS): 7 | var line = [] 8 | line.resize(1000) 9 | -------------------------------------------------------------------------------- /project32/tests/test_while_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | var description = "While time (one very long while)" 4 | 5 | 6 | func should_subtract_loop_duration(): 7 | return false 8 | 9 | 10 | func execute(): 11 | var i = 0 12 | while i < ITERATIONS: 13 | i += 1 14 | -------------------------------------------------------------------------------- /project4/main.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://c6bkp0g8ifiia"] 2 | 3 | [ext_resource type="Script" path="res://start.gd" id="1"] 4 | 5 | [node name="Node" type="Node"] 6 | script = ExtResource("1") 7 | -------------------------------------------------------------------------------- /project4/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=5 10 | 11 | [application] 12 | 13 | config/name="GDScript benchmark" 14 | run/main_scene="res://main.tscn" 15 | config/features=PackedStringArray("4.0", "Forward Plus") 16 | config/icon="res://icon.svg" 17 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/bunnymark/bunny.gd: -------------------------------------------------------------------------------- 1 | extends Sprite2D 2 | 3 | 4 | var vx = randi() % 200 + 50 5 | var vy = randi() % 200 + 50 6 | var ay = 980 7 | 8 | 9 | func _ready(): 10 | set_position(Vector2(50, 50)) 11 | set_process(true) 12 | 13 | 14 | func _process(delta): 15 | var pos = get_position() 16 | 17 | pos.x = pos.x + vx * delta 18 | pos.y = pos.y + vy * delta 19 | 20 | vy = vy + ay * delta 21 | 22 | if pos.x > 800: 23 | vx = -vx 24 | pos.x = 800 25 | 26 | if pos.x < 0: 27 | vx = abs(vx) 28 | pos.x = 0 29 | 30 | if pos.y > 600: 31 | vy = -0.85 * vy 32 | pos.y = 600 33 | if randf() > 0.5: 34 | vy = -(randi() % 1100 + 50) 35 | 36 | if pos.y < 0: 37 | vy = 0 38 | pos.y = 0 39 | 40 | set_position(pos) 41 | 42 | 43 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/bunnymark/bunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project4/scale_benchmarks/bunnymark/bunny.png -------------------------------------------------------------------------------- /project4/scale_benchmarks/bunnymark/bunny.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=3 uid="uid://clqsa3brgp8ey"] 2 | 3 | [ext_resource type="Texture2D" uid="uid://bw4x8rc5ag3x0" path="res://scale_benchmarks/bunnymark/bunny.png" id="1"] 4 | [ext_resource type="Script" path="res://scale_benchmarks/bunnymark/bunny.gd" id="2"] 5 | 6 | [node name="Bunny" type="Sprite2D"] 7 | texture = ExtResource("1") 8 | script = ExtResource("2") 9 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/bunnymark/bunnymark.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Bunnymark" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of bunnies" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | for i in range(0, 10): 18 | var bunny_scene : PackedScene = load("res://scale_benchmarks/bunnymark/bunny.tscn") 19 | var bunny = bunny_scene.instantiate() 20 | add_child(bunny) 21 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/bunnymark/bunnymark.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://d237kvghlf5if"] 2 | 3 | [ext_resource type="Script" path="res://scale_benchmarks/bunnymark/bunnymark.gd" id="1"] 4 | 5 | [node name="Node" type="Node"] 6 | script = ExtResource("1") 7 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/cube_spam/cube_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = BoxMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance3D.new() 19 | mi.mesh = mesh 20 | mi.position = Vector3(randf_range(-10, 10), randf_range(-10, 10), randf_range(-10, 10)) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/cube_spam_blank_environment/cube_spam_blank_environment.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = BoxMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance3D.new() 19 | mi.mesh = mesh 20 | mi.position = Vector3(randf_range(-10, 10), randf_range(-10, 10), randf_range(-10, 10)) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/cube_spam_blank_environment/cube_spam_blank_environment.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=3 uid="uid://dnqqswuf0rnyi"] 2 | 3 | [ext_resource type="Script" path="res://scale_benchmarks/cube_spam_blank_environment/cube_spam_blank_environment.gd" id="1"] 4 | 5 | [sub_resource type="Environment" id="Environment_xnpr1"] 6 | 7 | [node name="Node" type="Node"] 8 | script = ExtResource("1") 9 | 10 | [node name="WorldEnvironment" type="WorldEnvironment" parent="."] 11 | environment = SubResource("Environment_xnpr1") 12 | 13 | [node name="Camera" type="Camera3D" parent="."] 14 | transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30) 15 | current = true 16 | fov = 70.0 17 | far = 100.0 18 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/cube_spam_with_shadows/cube_spam_with_shadows.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming cubes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | var mesh = BoxMesh.new() 17 | for i in range(0, 100): 18 | var mi = MeshInstance3D.new() 19 | mi.mesh = mesh 20 | mi.position = Vector3(randf_range(-10, 10), randf_range(-10, 10), randf_range(-10, 10)) 21 | add_child(mi) 22 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/node_spam_with_process/node_spam_with_process.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Nodes with empty process function" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of processing nodes" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var processor_scene = load("res://scale_benchmarks/node_spam_with_process/processor.gd") 18 | for i in range(0, 1000): 19 | var processor = processor_scene.new() 20 | add_child(processor) 21 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/node_spam_with_process/node_spam_with_process.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://dgwavhs7ln8hk"] 2 | 3 | [ext_resource type="Script" path="res://scale_benchmarks/node_spam_with_process/node_spam_with_process.gd" id="1"] 4 | 5 | [node name="Node" type="Node"] 6 | script = ExtResource("1") 7 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/node_spam_with_process/processor.gd: -------------------------------------------------------------------------------- 1 | extends Node 2 | 3 | 4 | func _ready(): 5 | set_process(true) 6 | 7 | 8 | func _process(delta): 9 | pass 10 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/physics_spheres/physics_spheres.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming spheres with physics" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of spheres" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() - 7 14 | 15 | 16 | func process(delta): 17 | var scene : PackedScene = load("res://scale_benchmarks/physics_spheres/sphere_body.tscn") 18 | for i in range(0, 1): 19 | var s : Node3D = scene.instantiate() 20 | s.position = Vector3(randf_range(-1, 1), 50, randf_range(-1, 1)) 21 | add_child(s) 22 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/physics_spheres/sphere_body.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=3 uid="uid://oguot8h1cbod"] 2 | 3 | [sub_resource type="SphereShape3D" id="1"] 4 | 5 | [sub_resource type="SphereMesh" id="2"] 6 | radial_segments = 8 7 | rings = 4 8 | 9 | [node name="SphereBody" type="RigidBody3D"] 10 | 11 | [node name="CollisionShape" type="CollisionShape3D" parent="."] 12 | shape = SubResource("1") 13 | 14 | [node name="MeshInstance" type="MeshInstance3D" parent="."] 15 | visible = false 16 | mesh = SubResource("2") 17 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/sprite_spam/sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/project4/scale_benchmarks/sprite_spam/sprite.png -------------------------------------------------------------------------------- /project4/scale_benchmarks/sprite_spam/sprite_spam.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | 4 | func get_description(): 5 | return "Spamming sprites" 6 | 7 | 8 | func get_metric_description(): 9 | return "Number of sprites" 10 | 11 | 12 | func get_metric(): 13 | return get_child_count() 14 | 15 | 16 | func process(delta): 17 | var tex = load("res://scale_benchmarks/sprite_spam/sprite.png") 18 | for i in range(0, 100): 19 | var sprite = Sprite2D.new() 20 | sprite.texture = tex 21 | sprite.position = Vector2(randf_range(100, 400), randf_range(100, 400)) 22 | add_child(sprite) 23 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/sprite_spam/sprite_spam.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://ymlpt36k13s3"] 2 | 3 | [ext_resource type="Script" path="res://scale_benchmarks/sprite_spam/sprite_spam.gd" id="1"] 4 | 5 | [node name="Node" type="Node"] 6 | script = ExtResource("1") 7 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/unique_cube_spam_blank_environment/unique_cube_spam_blank_environment.gd: -------------------------------------------------------------------------------- 1 | extends "../scale_benchmark.gd" 2 | 3 | func get_description(): 4 | return "Spamming unique cube meshes with empty environment" 5 | 6 | 7 | func get_metric_description(): 8 | return "Number of cubes" 9 | 10 | 11 | func get_metric(): 12 | return get_child_count() - 2 13 | 14 | 15 | func process(delta): 16 | for i in range(0, 100): 17 | var mesh = BoxMesh.new() 18 | mesh.size = Vector3(1,1,1) * randf_range(0.9, 1.1) 19 | var mi = MeshInstance3D.new() 20 | mi.mesh = mesh 21 | mi.position = Vector3(randf_range(-10, 10), randf_range(-10, 10), randf_range(-10, 10)) 22 | add_child(mi) 23 | -------------------------------------------------------------------------------- /project4/scale_benchmarks/unique_cube_spam_blank_environment/unique_cube_spam_blank_environment.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=3 format=3 uid="uid://bkry6pky1t5sh"] 2 | 3 | [ext_resource type="Script" path="res://scale_benchmarks/unique_cube_spam_blank_environment/unique_cube_spam_blank_environment.gd" id="1_3maoo"] 4 | 5 | [sub_resource type="Environment" id="Environment_xnpr1"] 6 | 7 | [node name="Node" type="Node"] 8 | script = ExtResource("1_3maoo") 9 | 10 | [node name="WorldEnvironment" type="WorldEnvironment" parent="."] 11 | environment = SubResource("Environment_xnpr1") 12 | 13 | [node name="Camera" type="Camera3D" parent="."] 14 | transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 30) 15 | current = true 16 | fov = 70.0 17 | far = 100.0 18 | -------------------------------------------------------------------------------- /project4/start.gd: -------------------------------------------------------------------------------- 1 | 2 | extends Node 3 | 4 | func _ready(): 5 | var s = load("res://test_singleton.gd").new() 6 | add_child(s) 7 | s.begin_tests() 8 | get_tree().quit() 9 | 10 | 11 | -------------------------------------------------------------------------------- /project4/tests/test.gd: -------------------------------------------------------------------------------- 1 | 2 | # Set by the main test script 3 | var ITERATIONS := 0 4 | var tree_root : Node 5 | 6 | func get_description() -> String: 7 | return "" 8 | 9 | 10 | func can_run(context): 11 | return true 12 | 13 | 14 | func should_subtract_loop_duration() -> bool: 15 | return true 16 | 17 | 18 | func setup(): 19 | pass 20 | 21 | 22 | func execute(): 23 | pass 24 | 25 | 26 | #func get_variant_count() -> int: 27 | # return 1 28 | -------------------------------------------------------------------------------- /project4/tests/test_add_remove_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Add and remove node" 6 | 7 | 8 | func setup(): 9 | ITERATIONS /= 50 10 | 11 | 12 | func execute(): 13 | 14 | var root = tree_root 15 | var node = Node.new() 16 | 17 | # NOTE: I found this test is biased, and I can't do anything about it. 18 | # Godot appears to run it slower if there are more iterations. 19 | # Adding and removing nodes has a race condition over the time it takes. 20 | 21 | for i in range(0, ITERATIONS): 22 | root.add_child(node) 23 | root.remove_child(node) 24 | 25 | node.free() 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /project4/tests/test_constants_addition.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | const CONST01 = 0 4 | const CONST02 = 0 5 | 6 | 7 | func get_description() -> String: 8 | return "Add two constants" 9 | 10 | 11 | func execute(): 12 | for i in range(0,ITERATIONS): 13 | var x = CONST01 + CONST02 14 | -------------------------------------------------------------------------------- /project4/tests/test_constants_addition_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | const CONST01 = 0 5 | const CONST02 = 0 6 | const CONST03 = 0 7 | const CONST04 = 0 8 | const CONST05 = 0 9 | const CONST06 = 0 10 | const CONST07 = 0 11 | const CONST08 = 0 12 | const CONST09 = 0 13 | const CONST10 = 0 14 | 15 | 16 | func get_description() -> String: 17 | return "Add 10 constants" 18 | 19 | 20 | func execute(): 21 | for i in range(0, ITERATIONS): 22 | var x = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 23 | -------------------------------------------------------------------------------- /project4/tests/test_constants_addition_x10_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | const CONST01 := 0 4 | const CONST02 := 0 5 | const CONST03 := 0 6 | const CONST04 := 0 7 | const CONST05 := 0 8 | const CONST06 := 0 9 | const CONST07 := 0 10 | const CONST08 := 0 11 | const CONST09 := 0 12 | const CONST10 := 0 13 | 14 | 15 | func get_description() -> String: 16 | return "Add 10 constants (typed)" 17 | 18 | 19 | func execute(): 20 | for i in range(0, ITERATIONS): 21 | var x : int = CONST01 + CONST02 + CONST03 + CONST04 + CONST05 + CONST06 + CONST07 + CONST08 + CONST09 + CONST10 22 | -------------------------------------------------------------------------------- /project4/tests/test_deep_transform_3d_noget.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Deep transform change without querying leaf" 5 | 6 | var _root_spatial = null 7 | var _leaf_spatial = null 8 | 9 | 10 | func setup(): 11 | var root = tree_root 12 | for d in 10: 13 | var s = Node3D.new() 14 | s.set_name("Node3D") 15 | root.add_child(s) 16 | root = s 17 | _leaf_spatial = s 18 | _root_spatial = tree_root.get_node("Node3D") 19 | 20 | 21 | func execute(): 22 | var root = _root_spatial 23 | 24 | var t1 = Transform3D(Basis(), Vector3(1, 2, 3)) 25 | var t2 = Transform3D(Basis().rotated(Vector3(0, 1, 0), 33), Vector3()) 26 | 27 | var iterations = ITERATIONS / 2 28 | 29 | for i in range(0, iterations): 30 | root.set_transform(t1) 31 | root.set_transform(t2) 32 | -------------------------------------------------------------------------------- /project4/tests/test_dictionary_lookup_int.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Dictionary lookup with int key (x10)" 5 | 6 | 7 | var _dict : Dictionary = {} 8 | 9 | func setup(): 10 | for i in 100: 11 | _dict[i] = true 12 | 13 | 14 | func execute(): 15 | for i in range(0, ITERATIONS): 16 | _dict[0] 17 | _dict[10] 18 | _dict[20] 19 | _dict[30] 20 | _dict[40] 21 | _dict[50] 22 | _dict[60] 23 | _dict[70] 24 | _dict[80] 25 | _dict[90] 26 | 27 | -------------------------------------------------------------------------------- /project4/tests/test_dictionary_lookup_nodepath.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Dictionary lookup with NodePath key (x10)" 5 | 6 | 7 | var _dict : Dictionary = {} 8 | 9 | func setup(): 10 | for i in 100: 11 | _dict[NodePath(str("string_key_", i))] = true 12 | 13 | 14 | func execute(): 15 | for i in range(0, ITERATIONS): 16 | _dict[^"string_key_0"] 17 | _dict[^"string_key_10"] 18 | _dict[^"string_key_20"] 19 | _dict[^"string_key_30"] 20 | _dict[^"string_key_40"] 21 | _dict[^"string_key_50"] 22 | _dict[^"string_key_60"] 23 | _dict[^"string_key_70"] 24 | _dict[^"string_key_80"] 25 | _dict[^"string_key_90"] 26 | 27 | -------------------------------------------------------------------------------- /project4/tests/test_dictionary_lookup_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Dictionary lookup with string key (x10)" 5 | 6 | 7 | var _dict : Dictionary = {} 8 | 9 | func setup(): 10 | for i in 100: 11 | _dict[str("string_key_", i)] = true 12 | 13 | 14 | func execute(): 15 | for i in range(0, ITERATIONS): 16 | _dict["string_key_0"] 17 | _dict["string_key_10"] 18 | _dict["string_key_20"] 19 | _dict["string_key_30"] 20 | _dict["string_key_40"] 21 | _dict["string_key_50"] 22 | _dict["string_key_60"] 23 | _dict["string_key_70"] 24 | _dict["string_key_80"] 25 | _dict["string_key_90"] 26 | 27 | -------------------------------------------------------------------------------- /project4/tests/test_dictionary_lookup_stringname.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Dictionary lookup with StringName key (x10)" 5 | 6 | 7 | var _dict : Dictionary = {} 8 | 9 | func setup(): 10 | for i in 100: 11 | _dict[StringName(str("string_key_", i))] = true 12 | 13 | 14 | func execute(): 15 | for i in range(0, ITERATIONS): 16 | _dict[&"string_key_0"] 17 | _dict[&"string_key_10"] 18 | _dict[&"string_key_20"] 19 | _dict[&"string_key_30"] 20 | _dict[&"string_key_40"] 21 | _dict[&"string_key_50"] 22 | _dict[&"string_key_60"] 23 | _dict[&"string_key_70"] 24 | _dict[&"string_key_80"] 25 | _dict[&"string_key_90"] 26 | 27 | -------------------------------------------------------------------------------- /project4/tests/test_divide.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Divide" 5 | 6 | func execute(): 7 | var a = 9999 8 | for i in range(0, ITERATIONS): 9 | a /= 2 10 | -------------------------------------------------------------------------------- /project4/tests/test_divide_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Divide (typed)" 5 | 6 | func execute(): 7 | var a := 9999 8 | for i in range(0, ITERATIONS): 9 | a /= 2 10 | -------------------------------------------------------------------------------- /project4/tests/test_emit_signal.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Emit not-connected signal" 5 | 6 | signal test_signal 7 | 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | emit_signal("test_signal") 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_emit_signal_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Emit not-connected signal with very long name" 5 | 6 | signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 7 | 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | emit_signal("test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_emit_signal_long_name_stringname.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Emit not-connected signal with very long name using StringName" 5 | 6 | signal test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name 7 | 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | emit_signal(&"test_signal_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name_long_name") 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_emit_signal_v2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Emit not-connected signal using new Godot 4 syntax" 5 | 6 | signal test_signal 7 | 8 | 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | test_signal.emit() 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_empty_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Empty func (void function call cost)" 6 | 7 | 8 | func execute(): 9 | for i in range(0,ITERATIONS): 10 | empty_func() 11 | 12 | 13 | func empty_func(): 14 | pass 15 | 16 | -------------------------------------------------------------------------------- /project4/tests/test_engine_func.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Call engine func getter" 6 | 7 | 8 | func execute(): 9 | var obj = Node.new() 10 | for i in range(0,ITERATIONS): 11 | obj.get_index() 12 | obj.free() 13 | 14 | -------------------------------------------------------------------------------- /project4/tests/test_engine_func_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Call engine func getter (typed)" 6 | 7 | 8 | func execute(): 9 | var obj := Node.new() 10 | for i in range(0,ITERATIONS): 11 | obj.get_index() 12 | obj.free() 13 | 14 | -------------------------------------------------------------------------------- /project4/tests/test_engine_func_with_params.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Call engine func with params (str, bool, bool)" 6 | 7 | 8 | func execute(): 9 | var obj = Node.new() 10 | 11 | var a = "a" 12 | var b = false 13 | var c = false 14 | 15 | # Function was chosen for almost doing nothing C++ side 16 | for i in range(0,ITERATIONS): 17 | obj.find_child(a, b, c) 18 | 19 | obj.free() 20 | 21 | -------------------------------------------------------------------------------- /project4/tests/test_engine_func_with_params_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Call engine func with params (str, bool, bool) (typed)" 6 | 7 | 8 | func execute(): 9 | var obj := Node.new() 10 | 11 | var a := "a" 12 | var b := false 13 | var c := false 14 | 15 | # Function was chosen for almost doing nothing C++ side 16 | for i in range(0,ITERATIONS): 17 | obj.find_child(a, b, c) 18 | 19 | obj.free() 20 | 21 | -------------------------------------------------------------------------------- /project4/tests/test_engine_func_with_params_vcall.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Call engine func with params (str, bool, bool) using `call` (typed)" 6 | 7 | 8 | func execute(): 9 | var obj := Node.new() 10 | 11 | var a := "a" 12 | var b := false 13 | var c := false 14 | 15 | # Function was chosen for almost doing nothing C++ side 16 | for i in range(0,ITERATIONS): 17 | obj.call(&"find_child", a, b, c) 18 | 19 | obj.free() 20 | 21 | -------------------------------------------------------------------------------- /project4/tests/test_for_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "For time (one very long for)" 5 | 6 | 7 | func should_subtract_loop_duration(): 8 | return false 9 | 10 | 11 | func execute(): 12 | for i in range(0, ITERATIONS): 13 | pass 14 | -------------------------------------------------------------------------------- /project4/tests/test_func_with_params.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func.gd` 4 | func get_description() -> String: 5 | return "Call script class func(str, bool, bool)" 6 | 7 | 8 | class TestObj: 9 | func foo(a, b, c): 10 | pass 11 | 12 | 13 | func execute(): 14 | var obj = TestObj.new() 15 | 16 | var a = "" 17 | var b = false 18 | var c = false 19 | 20 | for i in range(0,ITERATIONS): 21 | obj.foo(a, b, c) 22 | 23 | 24 | -------------------------------------------------------------------------------- /project4/tests/test_func_with_params_callable.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func_typed.gd` 4 | func get_description() -> String: 5 | return "Call script class func(str, bool, bool) using Callable" 6 | 7 | class TestObj: 8 | func foo(a: String, b: bool, c: bool): 9 | pass 10 | 11 | 12 | func execute(): 13 | var obj = TestObj.new() 14 | 15 | var a := "" 16 | var b := false 17 | var c := false 18 | 19 | var callable : Callable = obj.foo 20 | 21 | for i in range(0,ITERATIONS): 22 | callable.call(a, b, c) 23 | 24 | -------------------------------------------------------------------------------- /project4/tests/test_func_with_params_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | # Arguments mimick `test_engine_func_typed.gd` 4 | func get_description() -> String: 5 | return "Call script class func(str, bool, bool) (typed)" 6 | 7 | class TestObj: 8 | func foo(a: String, b: bool, c: bool): 9 | pass 10 | 11 | 12 | func execute(): 13 | var obj := TestObj.new() 14 | 15 | var a := "" 16 | var b := false 17 | var c := false 18 | 19 | for i in range(0,ITERATIONS): 20 | obj.foo(a, b, c) 21 | 22 | -------------------------------------------------------------------------------- /project4/tests/test_get_node.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "get_node() where only one child" 5 | 6 | 7 | func setup(): 8 | var node = Node.new() 9 | node.set_name("GetNodeTest") 10 | tree_root.add_child(node) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node("GetNodeTest") 16 | -------------------------------------------------------------------------------- /project4/tests/test_get_node_10_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "get_node() where 10 children" 5 | 6 | 7 | func setup(): 8 | for i in 10: 9 | var n = Node.new() 10 | n.set_name("GetNodeTest_" + str(i)) 11 | tree_root.add_child(n) 12 | 13 | 14 | func execute(): 15 | for i in range(0, ITERATIONS): 16 | tree_root.get_node("GetNodeTest_9") 17 | -------------------------------------------------------------------------------- /project4/tests/test_get_node_10_children_3_deep.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "get_node() 3 parents deep having 10 children" 5 | 6 | 7 | func setup(): 8 | var root = tree_root 9 | for d in 3: 10 | for i in 10: 11 | var n = Node.new() 12 | n.set_name("GetNodeTest_" + str(i)) 13 | root.add_child(n) 14 | root = root.get_node("GetNodeTest_9") 15 | 16 | 17 | func execute(): 18 | for i in range(0, ITERATIONS): 19 | tree_root.get_node("GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 20 | -------------------------------------------------------------------------------- /project4/tests/test_get_node_10_children_3_deep_dollar.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "get_node() 3 parents deep having 10 children with $" 5 | 6 | # `$` is reserved to classes extending `Node`, but `test.gd` doesn't extend that 7 | class MyNode extends Node: 8 | var ITERATIONS 9 | func execute(): 10 | for i in range(0, ITERATIONS): 11 | $GetNodeTest_9/GetNodeTest_9/GetNodeTest_9 12 | 13 | var _my_node : MyNode 14 | 15 | func setup(): 16 | var root = tree_root 17 | _my_node = MyNode.new() 18 | _my_node.ITERATIONS = ITERATIONS 19 | root.add_child(_my_node) 20 | root = _my_node 21 | for d in 3: 22 | for i in 10: 23 | var n = Node.new() 24 | n.set_name("GetNodeTest_" + str(i)) 25 | root.add_child(n) 26 | root = root.get_node("GetNodeTest_9") 27 | 28 | 29 | func execute(): 30 | _my_node.execute() 31 | -------------------------------------------------------------------------------- /project4/tests/test_get_node_10_children_3_deep_nodepath.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "get_node() 3 parents deep having 10 children using a NodePath" 5 | 6 | 7 | func setup(): 8 | var root = tree_root 9 | for d in 3: 10 | for i in 10: 11 | var n = Node.new() 12 | n.set_name("GetNodeTest_" + str(i)) 13 | root.add_child(n) 14 | root = root.get_node("GetNodeTest_9") 15 | 16 | 17 | func execute(): 18 | for i in range(0, ITERATIONS): 19 | tree_root.get_node(^"GetNodeTest_9/GetNodeTest_9/GetNodeTest_9") 20 | -------------------------------------------------------------------------------- /project4/tests/test_get_node_nodepath.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "get_node() where only one child using a NodePath" 5 | 6 | 7 | func setup(): 8 | var node = Node.new() 9 | node.set_name("GetNodeTest") 10 | tree_root.add_child(node) 11 | 12 | 13 | func execute(): 14 | for i in range(0, ITERATIONS): 15 | tree_root.get_node(^"GetNodeTest") 16 | -------------------------------------------------------------------------------- /project4/tests/test_if_true.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "if(true) time" 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | if true: 9 | pass 10 | 11 | -------------------------------------------------------------------------------- /project4/tests/test_if_true_else.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "if(true)else time" 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | if true: 9 | pass 10 | else: 11 | pass 12 | -------------------------------------------------------------------------------- /project4/tests/test_image_get_pixel.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Image get pixel" 6 | 7 | 8 | func execute(): 9 | var im := Image.create(512, 512, false, Image.FORMAT_RGB8) 10 | 11 | for i in range(0, ITERATIONS): 12 | im.get_pixel(42, 84) 13 | 14 | -------------------------------------------------------------------------------- /project4/tests/test_image_set_pixel.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Image set pixel" 6 | 7 | 8 | func execute(): 9 | var im := Image.create(512, 512, false, Image.FORMAT_RGB8) 10 | 11 | for i in range(0, ITERATIONS): 12 | im.set_pixel(42, 84, Color(0.0, 0.0, 0.0)) 13 | 14 | -------------------------------------------------------------------------------- /project4/tests/test_increment.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment" 5 | 6 | func execute(): 7 | var a = 0 8 | for i in range(0, ITERATIONS): 9 | a += 1 10 | 11 | -------------------------------------------------------------------------------- /project4/tests/test_increment_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment (typed)" 5 | 6 | func execute(): 7 | var a := 0 8 | for i in range(0, ITERATIONS): 9 | a += 1 10 | 11 | -------------------------------------------------------------------------------- /project4/tests/test_increment_vector2.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment Vector2" 5 | 6 | func execute(): 7 | var a = Vector2(0,0) 8 | var b = Vector2(1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += b 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_increment_vector3.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment Vector3" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | var b = Vector3(1,1,1) 10 | 11 | for i in range(0, ITERATIONS): 12 | a += b 13 | -------------------------------------------------------------------------------- /project4/tests/test_increment_vector3_constant.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment Vector3 with constant" 5 | 6 | 7 | func execute(): 8 | var a = Vector3(0,0,0) 9 | 10 | for i in range(0, ITERATIONS): 11 | a += Vector3(1,1,1) 12 | -------------------------------------------------------------------------------- /project4/tests/test_increment_vector3_individual_xyz.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment Vector3 coordinate by coordinate" 5 | 6 | func execute(): 7 | var a = Vector3(0,0,0) 8 | var b = Vector3(1,1,1) 9 | 10 | for i in range(0, ITERATIONS): 11 | a.x += b.x 12 | a.y += b.y 13 | a.z += b.z 14 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_array_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with array member" 5 | 6 | func execute(): 7 | var a = 0 8 | var arr = [1] 9 | for i in range(0, ITERATIONS): 10 | a += arr[0] 11 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_array_member_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with array member using typed GDScript (TypedArray)" 5 | 6 | func execute(): 7 | var a := 0 8 | var arr : Array[int] = [1] 9 | for i in range(0, ITERATIONS): 10 | a += arr[0] 11 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_class_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with class member" 5 | 6 | class TestClassForMemberAccess: 7 | var x = 0 8 | 9 | func execute(): 10 | var a = 0 11 | var c = TestClassForMemberAccess.new() 12 | for i in range(0, ITERATIONS): 13 | a += c.x 14 | 15 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_class_member_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with class member (typed)" 5 | 6 | class TestClassForMemberAccess: 7 | var x := 0 8 | 9 | func execute(): 10 | var a := 0 11 | var c := TestClassForMemberAccess.new() 12 | for i in range(0, ITERATIONS): 13 | a += c.x 14 | 15 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_dictionary_member.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with dictionary member" 5 | 6 | 7 | func execute(): 8 | var a = 0 9 | var dic = {b = 1} 10 | for i in range(0,ITERATIONS): 11 | a += dic.b 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_local_inside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with local (inside loop)" 5 | 6 | func execute(): 7 | var a = 0 8 | 9 | for i in range(0, ITERATIONS): 10 | var b = 1 11 | a += b 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_local_outside_loop.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with local (outside loop)" 5 | 6 | func execute(): 7 | var a = 0 8 | var b = 1 9 | 10 | for i in range(0,ITERATIONS): 11 | a += b 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_member_var.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Increment with member var" 6 | 7 | var _test_a = 0 8 | 9 | 10 | func execute(): 11 | var a = 0 12 | for i in range(0,ITERATIONS): 13 | a += _test_a 14 | 15 | -------------------------------------------------------------------------------- /project4/tests/test_increment_with_member_var_using_self.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment with member var using self" 5 | 6 | var _test_a = 0 7 | 8 | 9 | func execute(): 10 | var a = 0 11 | for i in range(0,ITERATIONS): 12 | a += self._test_a 13 | 14 | -------------------------------------------------------------------------------- /project4/tests/test_increment_x5.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment (x5)" 5 | 6 | func execute(): 7 | var a = 0 8 | for i in range(0,ITERATIONS): 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | a += 1 14 | -------------------------------------------------------------------------------- /project4/tests/test_increment_x5_typed.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Increment (x5) (typed)" 5 | 6 | func execute(): 7 | var a := 0 8 | for i in range(0,ITERATIONS): 9 | a += 1 10 | a += 1 11 | a += 1 12 | a += 1 13 | a += 1 14 | -------------------------------------------------------------------------------- /project4/tests/test_int_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "IntArray set element" 5 | 6 | func execute(): 7 | var i_array = PackedInt32Array() 8 | i_array.resize(100) 9 | 10 | for i in range(0, ITERATIONS): 11 | i_array[42] = 0 12 | -------------------------------------------------------------------------------- /project4/tests/test_int_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "IntArray resize(1000)" 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | var line = PackedInt32Array() 9 | line.resize(1000) 10 | -------------------------------------------------------------------------------- /project4/tests/test_int_to_string.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "String str(i)" 5 | 6 | 7 | func execute(): 8 | for i in range(0, ITERATIONS): 9 | str(i) 10 | 11 | -------------------------------------------------------------------------------- /project4/tests/test_iterate_node_children_x100_get_child.gd: -------------------------------------------------------------------------------- 1 | extends "test_iterate_node_children_x10_get_child.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Iterate 100 node children using get_child" 6 | 7 | 8 | func _get_child_count_to_setup() -> int: 9 | return 100 10 | -------------------------------------------------------------------------------- /project4/tests/test_iterate_node_children_x100_get_children.gd: -------------------------------------------------------------------------------- 1 | extends "test_iterate_node_children_x10_get_children.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Iterate 100 node children using get_children" 6 | 7 | 8 | func _get_child_count_to_setup() -> int: 9 | return 100 10 | 11 | -------------------------------------------------------------------------------- /project4/tests/test_iterate_node_children_x10_get_child.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Iterate 10 node children using get_child" 6 | 7 | 8 | func _get_child_count_to_setup() -> int: 9 | return 10 10 | 11 | 12 | func setup(): 13 | for i in _get_child_count_to_setup(): 14 | tree_root.add_child(Node.new()) 15 | 16 | 17 | func execute(): 18 | var parent : Node = tree_root 19 | 20 | for i in range(0, ITERATIONS): 21 | for j in parent.get_child_count(): 22 | parent.get_child(j) 23 | 24 | -------------------------------------------------------------------------------- /project4/tests/test_iterate_node_children_x10_get_children.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | 4 | func get_description() -> String: 5 | return "Iterate 10 node children using get_children" 6 | 7 | 8 | func _get_child_count_to_setup() -> int: 9 | return 10 10 | 11 | 12 | func setup(): 13 | for i in _get_child_count_to_setup(): 14 | tree_root.add_child(Node.new()) 15 | 16 | 17 | func execute(): 18 | var parent : Node = tree_root 19 | 20 | for i in range(0, ITERATIONS): 21 | for child in parent.get_children(): 22 | pass 23 | 24 | -------------------------------------------------------------------------------- /project4/tests/test_just_comments.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Just 20 lines of comments (should take zero time on release build)" 5 | 6 | func execute(): 7 | for i in range(0, ITERATIONS): 8 | # Comment 1 9 | # Comment 2 10 | # Comment 3 11 | # Comment 4 12 | # Comment 5 13 | # Comment 6 14 | # Comment 7 15 | # Comment 8 16 | # Comment 9 17 | # Comment 10 18 | # Comment 11 19 | # Comment 12 20 | # Comment 13 21 | # Comment 14 22 | # Comment 15 23 | # Comment 16 24 | # Comment 17 25 | # Comment 18 26 | # Comment 19 27 | # Comment 20 28 | pass 29 | 30 | -------------------------------------------------------------------------------- /project4/tests/test_load.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Cost of load() (regardless of resource)" 5 | 6 | func execute(): 7 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 8 | var res = load("res://tests/test.gd") 9 | 10 | for i in range(0, ITERATIONS): 11 | load("res://tests/test.gd") 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_new_class.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Instance class (no member variables)" 5 | 6 | 7 | class TestClass1: 8 | func foo(): 9 | pass 10 | 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | TestClass1.new() 15 | -------------------------------------------------------------------------------- /project4/tests/test_new_class_with_10_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Instance class (10 member variables)" 5 | 6 | class TestClass10: 7 | var v0 = 0 8 | var v1 = 0 9 | var v2 = 0 10 | var v3 = 0 11 | var v4 = 0 12 | var v5 = 0 13 | var v6 = 0 14 | var v7 = 0 15 | var v8 = 0 16 | var v9 = 0 17 | func foo(): 18 | pass 19 | 20 | func execute(): 21 | for i in range(0, ITERATIONS): 22 | TestClass10.new() 23 | -------------------------------------------------------------------------------- /project4/tests/test_new_class_with_2_members.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Instance class (2 member variables)" 5 | 6 | class TestClass2: 7 | var x = 0 8 | var y = 0 9 | func foo(): 10 | pass 11 | 12 | func execute(): 13 | for i in range(0, ITERATIONS): 14 | TestClass2.new() 15 | -------------------------------------------------------------------------------- /project4/tests/test_new_class_with_long_name.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Instance class with long name (no member variables)" 5 | 6 | class TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName: 7 | func foo(): 8 | pass 9 | 10 | func execute(): 11 | for i in range(0, ITERATIONS): 12 | TestClassWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongNameWithLongName.new() 13 | 14 | -------------------------------------------------------------------------------- /project4/tests/test_preload.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Cost of preload() (regardless of resource)" 5 | 6 | func execute(): 7 | # Hold a reference to the resource so we are sure to only measure the time to fetch it from cache 8 | var res = preload("test.gd") 9 | 10 | for i in range(0, ITERATIONS): 11 | preload("test.gd") 12 | 13 | -------------------------------------------------------------------------------- /project4/tests/test_selection_with_if.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Switch using 10 ifs" 5 | 6 | 7 | func execute(): 8 | var v := 9 9 | 10 | for i in range(0, ITERATIONS): 11 | if v == 0: 12 | pass 13 | elif v == 1: 14 | pass 15 | elif v == 2: 16 | pass 17 | elif v == 3: 18 | pass 19 | elif v == 4: 20 | pass 21 | elif v == 5: 22 | pass 23 | elif v == 6: 24 | pass 25 | elif v == 7: 26 | pass 27 | elif v == 8: 28 | pass 29 | elif v == 9: 30 | pass 31 | -------------------------------------------------------------------------------- /project4/tests/test_selection_with_match.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Switch using match with 10 entries" 5 | 6 | 7 | func execute(): 8 | var v := 9 9 | 10 | for i in range(0, ITERATIONS): 11 | match v: 12 | 0: 13 | pass 14 | 1: 15 | pass 16 | 2: 17 | pass 18 | 3: 19 | pass 20 | 4: 21 | pass 22 | 5: 23 | pass 24 | 6: 25 | pass 26 | 8: 27 | pass 28 | 9: 29 | pass 30 | -------------------------------------------------------------------------------- /project4/tests/test_string_concat.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "String concat with 1 number" 5 | 6 | 7 | func execute(): 8 | var a = 42 9 | for i in range(0, ITERATIONS): 10 | "abc" + str(a) 11 | 12 | -------------------------------------------------------------------------------- /project4/tests/test_string_concat_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "String concat with 10 numbers" 5 | 6 | 7 | func setup(): 8 | # That test is quite long 9 | ITERATIONS /= 2 10 | 11 | 12 | func execute(): 13 | var a = 42 14 | for i in range(0, ITERATIONS): 15 | "abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a) + " abc " + str(a)+ " abc " + str(a) + " abc " + str(a) 16 | 17 | -------------------------------------------------------------------------------- /project4/tests/test_string_concat_x10_str_vararg.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "String concat with 10 numbers str vararg" 5 | 6 | 7 | func setup(): 8 | # That test is quite long 9 | ITERATIONS /= 2 10 | 11 | 12 | func execute(): 13 | var a = 42 14 | for i in range(0, ITERATIONS): 15 | str("abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a), " abc ", str(a)) 16 | 17 | -------------------------------------------------------------------------------- /project4/tests/test_string_format.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "String format with 1 number" 5 | 6 | 7 | func can_run(context): 8 | var v = context.engine_version.major 9 | return v != "1" and v != "2" 10 | 11 | 12 | func execute(): 13 | var a = 42 14 | for i in range(0, ITERATIONS): 15 | "abc {0}".format([a]) 16 | -------------------------------------------------------------------------------- /project4/tests/test_string_format_x10.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "String format with 10 numbers" 5 | 6 | 7 | func can_run(context): 8 | var v = context.engine_version.major 9 | return v != "1" and v != "2" 10 | 11 | 12 | func setup(): 13 | # This test takes long 14 | ITERATIONS /= 5 15 | 16 | 17 | func execute(): 18 | var a = 42 19 | for i in range(0, ITERATIONS): 20 | "abc {0} abc {1} abc {2} abc {3} abc {4} abc {5} abc {6} abc {7} abc {8} abc {9}".format([a,a,a,a,a,a,a,a,a,a]) 21 | -------------------------------------------------------------------------------- /project4/tests/test_unused_local.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "Unused local (declaration cost)" 5 | 6 | 7 | func execute(): 8 | for i in range(0, ITERATIONS): 9 | var b = 1 10 | -------------------------------------------------------------------------------- /project4/tests/test_variant_array_assign.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "VariantArray set element" 5 | 6 | 7 | func execute(): 8 | var v_array = [] 9 | v_array.resize(100) 10 | 11 | for i in range(0, ITERATIONS): 12 | v_array[42] = 0 13 | -------------------------------------------------------------------------------- /project4/tests/test_variant_array_resize.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "VariantArray resize(1000)" 5 | 6 | 7 | func execute(): 8 | for i in range(0, ITERATIONS): 9 | var line = [] 10 | line.resize(1000) 11 | -------------------------------------------------------------------------------- /project4/tests/test_while_time.gd: -------------------------------------------------------------------------------- 1 | extends "test.gd" 2 | 3 | func get_description() -> String: 4 | return "While time (one very long while)" 5 | 6 | 7 | func should_subtract_loop_duration(): 8 | return false 9 | 10 | 11 | func execute(): 12 | var i = 0 13 | 14 | while i < ITERATIONS: 15 | i += 1 16 | -------------------------------------------------------------------------------- /viewer/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zylann/gdscript_performance/8dc5380131c1f8d4ae2580e57ceef572451b1bc5/viewer/icon.png -------------------------------------------------------------------------------- /viewer/project.godot: -------------------------------------------------------------------------------- 1 | ; Engine configuration file. 2 | ; It's best edited using the editor UI and not directly, 3 | ; since the parameters that go here are not all obvious. 4 | ; 5 | ; Format: 6 | ; [section] ; section goes between [] 7 | ; param=value ; assign values to parameters 8 | 9 | config_version=5 10 | 11 | [application] 12 | 13 | config/name="Benchmark results viewer" 14 | run/main_scene="res://main.tscn" 15 | config/features=PackedStringArray("4.1") 16 | run/low_processor_mode=true 17 | config/icon="res://icon.png" 18 | 19 | [display] 20 | 21 | window/size/viewport_width=1200 22 | 23 | [gdnative] 24 | 25 | singletons=[] 26 | 27 | [rendering] 28 | 29 | quality/directional_shadow/size=512 30 | lights_and_shadows/shadow_atlas/size=512 31 | quality/reflections/atlas_size=512 32 | -------------------------------------------------------------------------------- /viewer/util.gd: -------------------------------------------------------------------------------- 1 | 2 | 3 | static func get_file_list(dir_path: String, exts: PackedStringArray) -> PackedStringArray: 4 | var dir = DirAccess.open(dir_path) 5 | if dir == null: 6 | var open_code := DirAccess.get_open_error() 7 | print("Cannot open directory! Code: " + str(open_code)) 8 | return PackedStringArray() 9 | var list := PackedStringArray() 10 | dir.list_dir_begin() 11 | for i in range(0, 1000): 12 | var file := dir.get_next() 13 | if file == "": 14 | break 15 | if not dir.current_is_dir(): 16 | var file_ext := file.get_extension() 17 | for ext in exts: 18 | if ext == file_ext: 19 | list.append(file) 20 | break 21 | return list 22 | --------------------------------------------------------------------------------