r/C_Programming 1d ago

i made lib that beets fmt lib

Enable HLS to view with audio, or disable this notification

i made logging in C that does not need formater% as printf instead it has auto-type detect via _Generic ,like fmt it uses {} as placeholder

i started it just for fun but later i notice that it is insanely fast it beets fmt lib and rust print 4.5x faster

it uses linux syscall write i might map syscall for windows latter

this is very interesting because i did not optimize the lib like convert from type to another use poor impl + i write in the buffer many times

write(1, logtag, strlen(logtag));

write(1, filename, strlen(filename)) ;

write(1, "->", 2);

write(1, function, strlen(function)) ;

write(1, " ", 1);

write(1, buffer, out);

so i guess after optimizing it will be 2x faster

all respect for fmt devs i inspired the {} from them btw

3 Upvotes

Duplicates