Cliff et al.,

I revisited the librt timer given your comment about it.  It does indeed track 
both user and wallclock time uing platform-specific means.  It also does its 
own string printing, but lets ignore that for now.  Code is in the various 
src/librt/timer-*.c per-platform files.

You’re right that it should be in libbu.  However, it can’t be moved as-is 
because it’s designed to use globals and we shouldn’t introduce any more 
globals to any lib.

To move it, we need an api either parallel to or replacing bu_gettime() and 
bu_utctime().  Fortunately, both those names kind of suck, so I’m thinking we 
just design a better replacement api.  The difficulty is that the current bu 
timer is really simple:

int64_t start = bu_gettime();
…
printf(“elapsed is %lf\n”, bu_gettime() - start);

The bu timer says its supposed to be a wallclock timer, which means it might be 
wrong on Windows due to the timer being used — I’ll check on that.  The only 
way I can see keeping any new usage that simple, **without introducing a whole 
other function**, is to have bu_gettime() take bitflags and perhaps return an 
array of int64_t’s (with the bitflags doubling as indices).  Something like 
this:

int64_t start[2], stop[2];
bu_time(&start, sizeof(start), BU_TIME_WALLCLOCK | BU_TIME_CPU);
…
bu_time(&stop, sizeof(stop), BU_TIME_WALLCLOCK);
printf(“elapsed is %lf\n”, stop[BU_TIME_WALLCLOCK] - start[BU_TIME_WALLCLOCK]);

There are obviously other options.  Anyone have any suggestions?  This would 
probably make a great couple GCI tasks… ;)

Cheers!
Sean


------------------------------------------------------------------------------
The Command Line: Reinvented for Modern Developers
Did the resurgence of CLI tooling catch you by surprise?
Reconnect with the command line and become more productive. 
Learn the new .NET and ASP.NET CLI. Get your free copy!
http://sdm.link/telerik
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to