Skip to content

Commit e9acc09

Browse files
committed
Sat_ID could be _very_ slow when reading large files with lots of spacecraft or roving observations, such as the ITF. I realized that a small performance observation made it run several times faster on such files. (Not much effect in general, however.)
1 parent 4b0e8de commit e9acc09

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

sat_id.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,8 +448,10 @@ static OBSERVATION *get_observations_from_file( FILE *ifile, size_t *n_found,
448448
void *ades_context = init_ades2mpc( );
449449
char buff[400];
450450
size_t count = 0, n_allocated = 0, n_offsets = 0, i;
451+
size_t n_obs_without_loc = 0;
451452
offset_t *offsets = NULL;
452453
int n_errors_found = 0;
454+
const clock_t t0 = clock( );
453455

454456
assert( ades_context);
455457
memset( &obs, 0, sizeof( OBSERVATION));
@@ -503,7 +505,24 @@ static OBSERVATION *get_observations_from_file( FILE *ifile, size_t *n_found,
503505
(n_allocated + 1) * sizeof( OBSERVATION));
504506
}
505507
rval[count] = obs;
508+
if( !rval[count].observer_loc[0] && !rval[count].observer_loc[1]
509+
&& !rval[count].observer_loc[2])
510+
{
511+
const OBSERVATION temp_swap = rval[count]; /* put obs w/out positions */
512+
/* at the start of array */
513+
rval[count] = rval[n_obs_without_loc];
514+
rval[n_obs_without_loc] = temp_swap;
515+
n_obs_without_loc++;
516+
}
506517
count++;
518+
if( count % 500000 == 0)
519+
{
520+
const clock_t dt = clock( ) - t0;
521+
522+
if( dt)
523+
fprintf( stderr, "%ld obs (%.0lf obs/second) \r",
524+
count, (double)count * (double)CLOCKS_PER_SEC / (double)dt);
525+
}
507526
}
508527
}
509528
else if( !strncmp( buff, "COM verbose ", 12))
@@ -525,7 +544,7 @@ static OBSERVATION *get_observations_from_file( FILE *ifile, size_t *n_found,
525544
{
526545
size_t j = 0;
527546

528-
while( j < count && !offset_matches_obs( offsets + i, rval + j))
547+
while( j < n_obs_without_loc && !offset_matches_obs( offsets + i, rval + j))
529548
j++;
530549
if( j == count)
531550
{

0 commit comments

Comments
 (0)