Skip to content

Commit 746fe56

Browse files
committed
Merge pull request #525 from asarium/cleanup/timer
Remove some unused code from timer.h/.cpp
2 parents a87af22 + fc6bc3a commit 746fe56

File tree

3 files changed

+1
-259
lines changed

3 files changed

+1
-259
lines changed

code/freespace2/freespace.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4448,7 +4448,6 @@ void game_frame(bool paused)
44484448
}
44494449
#endif
44504450
// start timing frame
4451-
timing_frame_start();
44524451
profile_begin("Main Frame");
44534452

44544453
DEBUG_GET_TIME( total_time1 )
@@ -4613,11 +4612,7 @@ void game_frame(bool paused)
46134612

46144613
// maybe render and process the dead popup
46154614
game_maybe_do_dead_popup(flFrametime);
4616-
4617-
// start timing frame
4618-
timing_frame_stop();
4619-
// timing_display(30, 10);
4620-
4615+
46214616
// If a regular popup is active, don't flip (popup code flips)
46224617
if( !popup_running_state() ){
46234618
DEBUG_GET_TIME( flip_time1 )

code/io/timer.cpp

Lines changed: 0 additions & 221 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
#include "osapi/osapi.h" // for multi-thread macros
2828

2929

30-
31-
#ifndef NDEBUG
32-
#define USE_TIMING
33-
#endif
34-
3530
#ifdef _WIN32
3631
static longlong Timer_last_value = 0, Timer_base = 0, Timer_freq = 0;
3732
static const int precision = 1;
@@ -288,219 +283,3 @@ int timestamp_has_time_elapsed(int stamp, int time)
288283
return 0;
289284
}
290285

291-
// timing functions -------------------------------------------------------------------------------
292-
293-
#define MAX_TIMING_EVENTS 15
294-
295-
// timing struct
296-
#ifdef USE_TIMING
297-
298-
typedef struct timing {
299-
char name[64];
300-
int microseconds_total;
301-
int start;
302-
int ref_count;
303-
} timing;
304-
305-
timing Timing_frame;
306-
timing Timing_events[MAX_TIMING_EVENTS];
307-
int Timing_event_count = 0;
308-
309-
#endif
310-
311-
// lookup a timing event
312-
int timing_event_lookup(char *event_name)
313-
{
314-
#ifndef USE_TIMING
315-
return -1;
316-
#else
317-
int idx;
318-
319-
// sanity
320-
if(event_name == NULL){
321-
return -1;
322-
}
323-
324-
// look through all events
325-
for(idx=0; idx<MAX_TIMING_EVENTS; idx++){
326-
if(!stricmp(Timing_events[idx].name, event_name)){
327-
return idx;
328-
}
329-
}
330-
331-
return -1;
332-
#endif
333-
}
334-
335-
// start timing frame stuff
336-
void timing_frame_start()
337-
{
338-
#ifndef USE_TIMING
339-
return;
340-
#else
341-
int idx;
342-
343-
// restart the frame
344-
Timing_event_count = 0;
345-
Timing_frame.start = timer_get_microseconds();
346-
for(idx=0; idx<MAX_TIMING_EVENTS; idx++){
347-
Timing_events[idx].microseconds_total = 0;
348-
strcpy_s(Timing_events[idx].name, "");
349-
Timing_events[idx].ref_count = 0;
350-
}
351-
#endif
352-
}
353-
354-
// done timing the frame
355-
void timing_frame_stop()
356-
{
357-
#ifndef USE_TIMING
358-
return;
359-
#else
360-
int stop_time;
361-
362-
// stop time
363-
stop_time = timer_get_microseconds();
364-
365-
// calc times
366-
Timing_frame.microseconds_total = stop_time - Timing_frame.start;
367-
#endif
368-
}
369-
370-
// get the total frame time in microseconds
371-
int timing_frame_total()
372-
{
373-
#ifndef USE_TIMING
374-
return 0;
375-
#else
376-
return Timing_frame.microseconds_total;
377-
#endif
378-
}
379-
380-
// time an individual event
381-
void timing_event_start(char *event_name)
382-
{
383-
#ifndef USE_TIMING
384-
return;
385-
#else
386-
int event;
387-
388-
// sanity
389-
if(event_name == NULL){
390-
return;
391-
}
392-
393-
// try and find the event
394-
event = timing_event_lookup(event_name);
395-
396-
// if we already have one
397-
if(event != -1){
398-
Assert(Timing_events[event].ref_count == 0);
399-
Timing_events[event].start = timer_get_microseconds();
400-
Timing_events[event].ref_count++;
401-
}
402-
// if we need to add a new one
403-
else {
404-
if(Timing_event_count < MAX_TIMING_EVENTS){
405-
strcpy_s(Timing_events[Timing_event_count].name, event_name);
406-
Timing_events[Timing_event_count].start = timer_get_microseconds();
407-
Timing_events[Timing_event_count++].ref_count++;
408-
}
409-
}
410-
#endif
411-
}
412-
413-
// stop timing an event
414-
void timing_event_stop(char *event_name)
415-
{
416-
#ifndef USE_TIMING
417-
return;
418-
#else
419-
int event;
420-
421-
// sanity
422-
if(event_name == NULL){
423-
return;
424-
}
425-
426-
// try and find the event
427-
event = timing_event_lookup(event_name);
428-
429-
// if we already have one
430-
if(event != -1){
431-
Assert(Timing_events[event].ref_count == 1);
432-
Timing_events[event].microseconds_total += timer_get_microseconds() - Timing_events[event].start;
433-
Timing_events[event].ref_count--;
434-
}
435-
#endif
436-
}
437-
438-
// get the total time for an event in microseconds
439-
int timing_event_total(char *event_name)
440-
{
441-
#ifndef USE_TIMING
442-
return -1;
443-
#else
444-
int event;
445-
446-
// sanity
447-
if(event_name == NULL){
448-
return -1;
449-
}
450-
451-
// try and find the event
452-
event = timing_event_lookup(event_name);
453-
if(event == -1){
454-
return -1;
455-
}
456-
457-
return Timing_events[event].microseconds_total;
458-
#endif
459-
}
460-
461-
// get the percentage of total frametime for the event (0.0 to 1.0)
462-
float timing_event_pct(char *event_name)
463-
{
464-
#ifndef USE_TIMING
465-
return 0.0f;
466-
#else
467-
int event;
468-
469-
// sanity
470-
if(event_name == NULL){
471-
return -1.0f;
472-
}
473-
474-
// try and find the event
475-
event = timing_event_lookup(event_name);
476-
if(event == -1){
477-
return -1.0f;
478-
}
479-
480-
return (float)((double)Timing_events[event].microseconds_total / (double)Timing_frame.microseconds_total);
481-
#endif
482-
}
483-
484-
// display timing
485-
void timing_display(int x, int y)
486-
{
487-
#ifndef USE_TIMING
488-
return;
489-
#else
490-
int idx;
491-
492-
int line_height = gr_get_font_height() + 1;
493-
494-
gr_set_color_fast(&Color_bright_blue);
495-
496-
// total time
497-
gr_printf_no_resize(x, y, "Total time %f\n", (float)timing_frame_total() / 1000000.0f);
498-
y += line_height;
499-
500-
// each event percentage
501-
for(idx=0; idx<Timing_event_count; idx++){
502-
gr_printf_no_resize(x, y, "%s: %f\n", Timing_events[idx].name, timing_event_pct(Timing_events[idx].name));
503-
y += line_height;
504-
}
505-
#endif
506-
}

code/io/timer.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828

2929
extern void timer_init();
3030
extern void timer_close();
31-
extern void timer_set_rate(int count_val);
32-
extern void timer_set_function( void * function );
3331

3432
//==========================================================================
3533
// These functions return the time since the timer was initialized in
@@ -48,10 +46,6 @@ extern uint timer_get_high_res_microseconds();
4846
extern int timer_get_seconds(); // seconds since program started... not accurate, but good for long
4947
// runtimes with second-based timeouts
5048

51-
//==========================================================================
52-
// Use to access the BIOS ticker... ie... i = TICKER
53-
void timer_delay(fix seconds);
54-
5549

5650
//=================================================================
5751
//=================================================================
@@ -120,30 +114,4 @@ int timestamp_has_time_elapsed(int stamp, int time);
120114
#define timestamp_elapsed_safe(_a, _b) ( (_a != 0) ? (((timestamp_ticker >= (_a)) || (timestamp_ticker < (_a - (_b + 100)))) ? 1 : 0) : 1 )
121115

122116

123-
// timing functions -------------------------------------------------------------------------------
124-
125-
// start timing frame stuff
126-
void timing_frame_start();
127-
128-
// done timing the frame
129-
void timing_frame_stop();
130-
131-
// get the total frame time in microseconds
132-
int timing_frame_total();
133-
134-
// time an individual event
135-
void timing_event_start(char *event_name);
136-
137-
// stop timing an event
138-
void timing_event_stop(char *event_name);
139-
140-
// get the total time for an event in microseconds
141-
int timing_event_total(char *event_name);
142-
143-
// get the percentage of total frametime for the event (0.0 to 1.0)
144-
float timing_event_pct(char *event_name);
145-
146-
// display timing
147-
void timing_display(int x, int y);
148-
149117
#endif

0 commit comments

Comments
 (0)