Add performance benchmarks

This patch shows the time it took to parse and type check a program
which can be great to know where to optimize.

Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
Slendi 2024-05-03 23:48:37 +02:00
parent 2e38b9dabc
commit ee979eb216

View File

@ -2,6 +2,7 @@ package main
import "core:fmt"
import "core:os"
import "core:time"
main :: proc() {
handle: os.Handle
@ -33,7 +34,11 @@ main :: proc() {
lexer := lexer_create(&u8_arr, file_name)
parser := parser_create(lexer)
parser_time_start := time.now()
ast := parser_parse(&parser)
parser_duration := time.since(parser_time_start)
defer fmt.printf("Parsing took: {}ns\n", time.duration_nanoseconds(parser_duration))
if len(g_message_list) > 0 {
contains_errors := false
for &msg in g_message_list {
@ -47,7 +52,12 @@ main :: proc() {
}
}
clear(&g_message_list)
type_check_start := time.now()
type_check(ast, nil)
type_check_duration := time.since(type_check_start)
defer fmt.printf("Type checker took: {}ns\n", time.duration_nanoseconds(type_check_duration))
if len(g_message_list) > 0 {
contains_errors := false
for &msg in g_message_list {