Performance evaluation of Multithreading, Hashtables, and Anonymous Functions for Rust and C++ : in Game Development

University essay from Blekinge Tekniska Högskola/Institutionen för datavetenskap

Abstract: Background C++ is a programming language introduced in 1985, while Rust was introduced in 2010. Rust focuses on speed and safety and was created with the need for concurrency in mind.These languages have different memory management systems as C++ originally only supported manual memory management, while Rust's memory management system performs checks before the compilation of the application begins to prevent issues such as dereferencing null pointers, use-after-free errors, and buffer overflows.These languages' standard libraries have some features in common such as anonymous functions,  hashtables, and threads.These features can be utilized in games by implementing resource management with hashtables, event systems with anonymous functions, and parallelization with threads. Objectives The objectives included designing two equivalent game implementations, one with Rust and one with C++. These games were the testing grounds used to test the standard library implementations of anonymous functions, hashtables, and threads. These features' execution times were measured and compared to determine if there existed a difference between them in Rust and C++. Methods Using Raylib, two identical games have been created that utilized and collected execution time metrics for anonymous functions, hashtables, and threads. These games were executed 90 times for a duration of 10 seconds. When all tests were completed, the execution time data was compiled. This data was visualized and analyzed to determine the differences in execution time between Rust and C++ for these specific features. Results The results indicate that Rust performs better at creating anonymous functions, searching and deleting entries in hashtables, and joining threads. The results also reveal that C++ performs better at calling anonymous functions, inserting into hashtables, and creating and starting threads. Conclusions A substantial statistical difference exists between the execution times for the selected features in Rust and C++. The performance differences are significant to the extent that a developer can gain some performance by selecting the language that performs best depending on their needs. In the end, both languages are well suited for game development based on the result of this limited study.

  AT THIS PAGE YOU CAN DOWNLOAD THE WHOLE ESSAY. (follow the link to the next page)