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:
parent
2e38b9dabc
commit
ee979eb216
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import "core:fmt"
|
import "core:fmt"
|
||||||
import "core:os"
|
import "core:os"
|
||||||
|
import "core:time"
|
||||||
|
|
||||||
main :: proc() {
|
main :: proc() {
|
||||||
handle: os.Handle
|
handle: os.Handle
|
||||||
@ -33,7 +34,11 @@ main :: proc() {
|
|||||||
lexer := lexer_create(&u8_arr, file_name)
|
lexer := lexer_create(&u8_arr, file_name)
|
||||||
parser := parser_create(lexer)
|
parser := parser_create(lexer)
|
||||||
|
|
||||||
|
parser_time_start := time.now()
|
||||||
ast := parser_parse(&parser)
|
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 {
|
if len(g_message_list) > 0 {
|
||||||
contains_errors := false
|
contains_errors := false
|
||||||
for &msg in g_message_list {
|
for &msg in g_message_list {
|
||||||
@ -47,7 +52,12 @@ main :: proc() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
clear(&g_message_list)
|
clear(&g_message_list)
|
||||||
|
|
||||||
|
type_check_start := time.now()
|
||||||
type_check(ast, nil)
|
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 {
|
if len(g_message_list) > 0 {
|
||||||
contains_errors := false
|
contains_errors := false
|
||||||
for &msg in g_message_list {
|
for &msg in g_message_list {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user