Exemplo n.º 1
0
int main()
{
    int i,first=1;
    char s[200];

    do {
        if(gets(s)==NULL) break;
        sscanf(s,"%d %d %d %d %d %d %d",&numroom,&numbed,&start,&trans,&roomprep,
               &bedprep,&numpat);
        for(i=0; i<numpat; i++) {
            gets(pat_name[i]);
            gets(s);
            sscanf(s,"%d %d",&pat_sur[i],&pat_rec[i]);
        }

        /* init */

        start*=60;
        clock=start;
        for(i=0; i<numpat; i++) {
            pat_room[i]=pat_bed[i]=-1;
            pat_status[i]=pat_trans[i]=0;
        }
        for(i=0; i<numroom; i++) {
            room_occ[i]=0;
            room_pat[i]=-1;
            room_prep[i]=0;
        }
        for(i=0; i<numbed; i++) {
            bed_occ[i]=0;
            bed_pat[i]=-1;
            bed_prep[i]=0;
        }
        patdone=0;

        /* start simulation */

        do {
            move_to_surgery();
            move_to_rec();
            elapse_time();
        } while(patdone<numpat);

        /* output */

        printf(" Patient          Operating Room          Recovery Room\n");
        printf(" #  Name     Room#  Begin   End      Bed#  Begin    End\n");
        printf(" ------------------------------------------------------\n");
        for(i=0; i<numpat; i++) {
            printf("%2d  %-9s %2d   %2d:%02d",i+1,pat_name[i],pat_room[i]+1,
                   pat_opb[i]/60,pat_opb[i]%60);
            printf("   %2d:%02d     %2d   %2d:%02d   %2d:%02d\n",pat_ope[i]/60,
                   pat_ope[i]%60,pat_bed[i]+1,pat_recb[i]/60,pat_recb[i]%60,
                   pat_rece[i]/60,pat_rece[i]%60);
        }
        printf("\nFacility Utilization\n");
        printf("Type  # Minutes  %% Used\n");
        printf("-------------------------\n");
        for(i=0; i<numroom; i++)
            printf("Room %2d    %4d  %6.2f\n",i+1,room_occ[i],
                   (float)room_occ[i]*100/(clock-start));
        for(i=0; i<numbed; i++)
            printf("Bed  %2d    %4d  %6.2f\n",i+1,bed_occ[i],
                   (float)bed_occ[i]*100/(clock-start));
        putchar('\n');
        if(gets(s)==NULL) break;
    } while(1);
}
Exemplo n.º 2
0
int main( int argc, char **argv )
{
    if( argc < 4 )
    {
        std::cout << "Usage: " << argv[0] << " <path-to-wc-file> <num-calls> <recurse>" << std::endl;
        std::cout << "       " << argv[0] << " readme.txt 50 0" << std::endl;
        std::cout << "       " << argv[0] << " ../Sources 1 1" << std::endl;
        return 1;
    }
    apr_initialize();
    apr_pool_initialize();

    apr_pool_t *m_pool;

    apr_pool_create( &m_pool, NULL );

    svn_config_ensure( "", m_pool );

    svn_client_ctx_t    m_context;
    memset( &m_context, 0, sizeof( m_context ) );

    // get the config based on the config dir passed in
    svn_config_get_config( &m_context.config, "", m_pool );

    apr_pool_t *pool = svn_pool_create( NULL );

    svn_opt_revision_t revision;
    revision.kind = svn_opt_revision_working;


    char *path = argv[1];

    svn_boolean_t recurse = atoi( argv[3] );

    int t0 = elapse_time();

    int max_calls = atoi( argv[2] );
    int i;
    for( i=0; i<max_calls; i++ )
    {
        apr_array_header_t *props = NULL;

        svn_error_t *error = svn_client_proplist
            (
            &props,
            path,
            &revision,
            recurse,
            &m_context,
            pool
            );
    }

    int t1 = elapse_time();

    int total = t1 - t0;

    std::cout << "Time for " << max_calls << " calls " << total << "ms recurse=" << recurse << std::endl;
    std::cout << "Time for " << 1 << " call " << total/max_calls << "ms recurse=" << recurse << std::endl;

    return 0;
}