KR Game Studios

Logo

Making Games on a Shoestring Budget!

Games & Software

11 January 2025

I Am Speed

by Kayne Ruse (Ratstail91)

I’ve just ran a speed test, comparing Toy v1 against Toy v2. After a long day coding, I’m worn out - let’s get straight to the data. I’ll likely add more data down the road, such as comparisons without the debugging, and with optimizations turned all the way up.

Setup And Build Options

v1 commit: b602e2ff87ab32b48024bc235d3963e6d2459ff2
v2 commit: 9141102f2e9896e5abdc9506d878b4dd50732422
Hardware: Raspberry Pi v5 8GB

The following script runs correctly in both versions, because it lacks any of the fancy syntax.

//calculate the nth fibonacci number, and print it
var counter: int = 0;

var first: int = 1;
var second: int = 0;

while (counter < 100_000) {
		var third: int = first + second;
		first = second;
		second = third;

		print third;

		++counter;
}

Here’s a summary of the command line options passed to GCC, slightly rearranged for clarity.

#v1
#libtoy.so
CC=gcc
CFLAGS+=\
	-std=c18 \
	-pedantic \
	-Werror \
	-I. \
	-g \
	-Wall \
	-W \
	-Wno-unused-parameter \
	-Wno-unused-function \
	-Wno-unused-variable \
	-Wl,-rpath,. \
	-Wl,--out-implib=../$(TOY_OUTDIR)/lib$(OUTNAME).a \
	-Wl,--whole-archive $(OBJ) \
	-Wl,--no-whole-archive \
	-fPIC
LIBS+=

#toyrepl
CFLAGS+=\
	-DTOY_IMPORT \
	-std=c18 \
	-pedantic \
	-Werror \
	-I../source \
	-g \
	-Wall \
	-W \
	-Wno-unused-parameter \
	-Wno-unused-function \
	-Wno-unused-variable \
	-Wl,-rpath,. \
	-L$(realpath $(shell pwd)/../$(TOY_OUTDIR))
LIBS+=-ltoy -lm
#v2
#libToy.so
CFLAGS=\
	-std=c17 \
	-g \
	-Wall \
	-Werror \
	-Wextra \
	-Wpedantic \
	-Wformat=2 \
	-shared \
	-Wl,-rpath,. \
	-Wl,--out-implib=$(SRC_OUTDIR)/lib$(SRC_TARGETNAME).a \
	-Wl,--whole-archive $(SRC_OBJFILES) \
	-Wl,--no-whole-archive \
	-fPIC
LIBS+=-lm

#repl.exe
CFLAGS=\
	-std=c17 \
	-g \
	-Wall \
	-Werror \
	-Wextra \
	-Wpedantic \
	-Wformat=2
LIBS+=-lm -lToy
LDFLAGS+=-Wl,-rpath,'$$ORIGIN'

Results!

Version & Run Real Time User Time System Time
v1 Run 1 0m1.642s 0m0.649s 0m0.260s
v1 Run 2 0m1.406s 0m0.657s 0m0.245s
v1 Run 3 0m1.432s 0m0.610s 0m0.278s
v2 Run 1 0m1.505s 0m0.427s 0m0.294s
V2 Run 2 0m1.088s 0m0.471s 0m0.245s
V2 Run 3 0m1.444s 0m0.475s 0m0.234s

All Times Compared

Times Stacked

Conclusion

This is the first time since I started the rewrite that I’ve been able to see clearly that my efforts are paying off.

Yeeeeeeeeee! Gonna lie down now.

Edit: I should probably link to the code, shouldn’t I?

toylang preview

tags: langdev - coding