Like Tree3Likes
  • 2 Post By Salem
  • 1 Post By Salem

Help to optimize the function in C

This is a discussion on Help to optimize the function in C within the C Programming forums, part of the General Programming Boards category; I am working on a C function for speed optimizaion. Below Function is taking 3-5 sec of time to complete, ...

  1. #1
    Registered User
    Join Date
    Jan 2013
    Posts
    13

    Help to optimize the function in C

    I am working on a C function for speed optimizaion. Below Function is taking 3-5 sec of time to complete, I want to reduce the time. Can somebody consult/help with some tips on how to achieve the desired result.

    Code:
    void
    Code:
     FormatMatrixComp(double * matrix, int *nmat, int *nrow, int *ncol, int * comp_flag, int * idbaseMat, int * idtargetMat)
    {
    
    int i,j,k,p;
    
    struct MG1G1_ * ptTargetMat; // will be used to point to target matrix depending on value of idtargetMat
    // initialization of structures
    // char * cpReadString = ( char * ) malloc ( 1024 ) ;
    // char * cpFileName = ( char * ) malloc ( 1024 ) ;
    
    char * cpFileName = NULL; // not needed in this version
    
    FILE * fStream = NULL; // dummy file pointer
    
    int nRow = 0;
    
    int nColumn = 0;
    
    int nComp = 0;
    
    short tempMG1G1Created = 0;
    
    static nrow_old = 0;
    
    static firsttime = 1;
    
    #ifdef PROFILE
    clock_t start,finish;
    
    double duration;
    
    #endif
     
    
    // memory allocation of structure (only if dimension changed since last call)
    // all other temporary structures used within this function call
    
    #ifdef PROFILE
    if(firsttime) fprintf(profile_file, "routine: FormatMatrixComp\n");
    if(firsttime) fprintf(profile_file, "-----------------------\n");
    if(firsttime) fprintf(profile_file, "\n");
    if(firsttime) start = clock();
    
    #endif
     
    
    // initialize ams structure to zero
    
    for(nComp =0; nComp< tempAMSdata.nComp_d;++nComp)
    {
    for(i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip ; ++i )
    {
    for(j = 0; j<10; ++j)
    tempAMSdata.stpDcomp[nComp].fpProps[i][j] = 0;
    }
    for(i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip ; ++i ) 
    {
    for(j = 0; j<3; ++j)
    tempAMSdata.stpDcomp[nComp].fpCoords[i][j] = 0;
    }
    }
    
    // loop over all matrices
    
    for (p=0; p<*nmat; p++)
    {
    lpdata.nBalasts = *nrow;
    
    if(*nrow != nrow_old)
    {
    // free memory allocated for structure in second and third dimension before reallocating first dimension
    
    for(i = 0; i < nrow_old; ++i)
    {
    for(j = 0; j < 1; ++j )
    free(lpdata.stBalast[i].lpBalastMatrix[j]);
    free(lpdata.stBalast[i].lpBalastMatrix);
    }
    // reallocate structure with new dimensions
    
    lpdata.stBalast = (struct balast_section *) realloc (lpdata.stBalast, sizeof (struct balast_section) * *nrow);
    for(i = 0; i < *nrow; ++i){
    lpdata.stBalast[i].lpBalastMatrix = ( double ** ) malloc ( sizeof ( double * ) * 1);
    for(j = 0; j < 1; ++j )
    {
    lpdata.stBalast[i].lpBalastMatrix[j] = ( double * ) malloc ( sizeof ( double ) * 10) ;
    for(k = 0 ; k < 10 ; ++k)
    {
    lpdata.stBalast[i].lpBalastMatrix[j][k] = 0; // initialize values to zero
    
    }
    }
    }
    // remember old dimensions
    
    nrow_old = *nrow;
    }
     
    
    // storage of FORTRAN matrix
     
    
    for (k=0; k<*ncol; k++)
    {
    for (i=0; i<*nrow; i++)
    {
    lpdata.stBalast[i].nRows = 1;
    lpdata.stBalast[i].nColumns = *ncol;
    lpdata.stBalast[i].lpBalastMatrix[0][k] = *(matrix++);
    }
    }
     
    
     
     
    
    if( ! createLPams( cpFileName, &stGeoxData, &stG2SData,&lpdata,&tempAMSdata,comp_flag))
    {
    // printf( "\n\ file creation Failed..............\n" ) ;
    
    // fputs( "\file creation Failed..............", fStream ) ;
    
    }
    else
    
    {
    // printf( "\ file creation successful..............\n" ) ;
    
    // fputs( "\ file creation successful..............", fStream ) ;
    
    LPAMSCreated =1;
    }
    if (LPAMSCreated==1)
    {
    // printf( "\ File creation is complete..............\n" ) ;
    
    // fputs( "\ File creation is complete..........", fStream ) ;
    
    }
    (comp_flag++);
    } // loop over all matrices
    
    #ifdef PROFILE
    if(firsttime) finish = clock();
    if(firsttime) duration = (double)(finish - start) / CLOCKS_PER_SEC;
    if(firsttime) fprintf(profile_file, "create structure:\t\t\t\t\t%8.4f\n", duration);
    
    #endif
    
    // Write file for validation purposes
    
    
    /*********************************************************************/
    /* CREATE MATRIX FROM STRUCTURE ... */
    /*********************************************************************/
     
    /********************************Processing Files Operation *****************************/
    
    stReturn = GetOnesMetrixDouble( tempMG1G1.dbpMG1G1_data, tempMG1G1.nRow, tempMG1G1.nColumn, 0 ); // initialize tempMG1G1 to zero
    
    #ifdef PROFILE
    if(firsttime) start = clock();
    
    #endif
    
    if(0 == ProcessMatrixData( &stProjectSpace, &tempAMSdata,
    &stGeoxData, &stMatrixdata, &stG2SData,&tempMG1G1, fStream ))
    {
    
    
    }
    else
    
    {
    tempMG1G1Created =1;
    stReturn = GetOnesMetrixDouble( stouttempMG1G1->dbpMG1G1_data, stouttempMG1G1->nRow,stouttempMG1G1->nColumn, 0 );
    if(0 == ConvertToG1SixMatrix(&tempMG1G1, stouttempMG1G1))
    { 
    stReturn = 0;
    }
    else{
    
    stReturn = 1;
    }
    }
    
    #ifdef PROFILE
    if(firsttime) finish = clock();
    if(firsttime) duration = (double)(finish - start) / CLOCKS_PER_SEC;
    if(firsttime) fprintf(profile_file, "ProcessMatrixData:\t\t\t\t\t\t\t\t%8.4f\n", duration);
    
    #endif
    
     
    /***************************************************************************************/
    /* MERGE CREATED MATRIX WITH BASE MATRIX TO CREATE TARGET MATRIX ... */
    /***************************************************************************************/
    
    #ifdef PROFILE
    if(firsttime) start = clock();
    
    #endif
    
    // select target matrix according to value of switch idbaseMat
    
    switch(*idtargetMat)
    {
    case OWE_ID:
    ptTargetMat = &stoutMg1g1OWE;
    break;
    case ZFW_ID:
    ptTargetMat = &stMg1g1ZFW;
    break;
    case CS_ID:
    ptTargetMat = &stMg1g1CS;
    break;
    }
    stReturn = GetOnesMetrixDouble( ptBaseMat->dbpMG1G1_data, ptBaseMat->nRow,ptBaseMat->nColumn, 0 ); 
    
    // initialize structure to zero
    // copy values of original baseMat to temporary baseMat container row by row to prevent mixing up of data in the merging process
    // (which matrix to select as baseMat depends on value of input flag idbaseMat)
    
    for(nRow =0;nRow<ptBaseMat->nRow;++nRow){
    switch(*idbaseMat)
    {
    case OWE_ID:
    memcpy(ptBaseMat->dbpMG1G1_data[nRow],stoutMg1g1OWE.dbpMG1G1_data[nRow],sizeof ( double ) * ptBaseMat->nColumn);
    
    break;
    case ZFW_ID:
    memcpy(ptBaseMat->dbpMG1G1_data[nRow],stMg1g1ZFW.dbpMG1G1_data[nRow],sizeof ( double ) * ptBaseMat->nColumn);
    
    break;
    case CS_ID:
    memcpy(ptBaseMat->dbpMG1G1_data[nRow],stMg1g1CS.dbpMG1G1_data[nRow],sizeof ( double ) * ptBaseMat->nColumn);
    
    break;
    }
    }
     
    
    // initialize values of target matrix and cg matrix to zero
    
    stReturn = GetOnesMetrixDouble( ptTargetMat->dbpMG1G1_data, ptTargetMat->nRow,ptTargetMat->nColumn, 0 );
    stReturn = GetOnesMetrixDouble(CGMatrix, ptTargetMat->nRow,3, 0 );
    // merge created matrix with base matrix to create target matrix
    
    if(0== MergeMatrices(ptBaseMat,stouttempMG1G1, &stGeoxData,ptTargetMat,CGMatrix))
    {
    stReturn = 0;
    
    }
    else
    
    {
    stReturn = 1;
    
    }
    
    #ifdef PROFILE
    if(firsttime) finish = clock();
    if(firsttime) duration = (double)(finish - start) / CLOCKS_PER_SEC;
    if(firsttime) fprintf(profile_file, "merge matrices:\t\t\t\t\t\t\t\t\t%8.4f\n", duration);
    
    #endif
     
    #ifdef PROFILE
    // close profile
    
    if(firsttime) fclose(profile_file);
    
    #endif
    if(firsttime) firsttime = 0;
    } // end of function 
    
    
    
    



    Tools I am using


    Visual studio 2008

    Windows XP

    Thank you very much.

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    You should really work on your presentation if you want people to help you for free.
    Code:
    void FormatMatrixComp(double *matrix, int *nmat, int *nrow, int *ncol, int *comp_flag,
                          int *idbaseMat, int *idtargetMat)
    {
      int i, j, k, p;
      struct MG1G1_ *ptTargetMat;   // will be used to point to target matrix depending on value of idtargetMat
      // initialization of structures
      // char * cpReadString = ( char * ) malloc ( 1024 ) ;
      // char * cpFileName = ( char * ) malloc ( 1024 ) ;
    
      char *cpFileName = NULL;      // not needed in this version
      FILE *fStream = NULL;         // dummy file pointer
      int nRow = 0;
      int nColumn = 0;
      int nComp = 0;
      short tempMG1G1Created = 0;
      static nrow_old = 0;
      static firsttime = 1;
    
    #ifdef PROFILE
      clock_t start, finish;
      double duration;
    #endif
       
      // memory allocation of structure (only if dimension changed since last call)
      // all other temporary structures used within this function call
    #ifdef PROFILE
      if (firsttime)
        fprintf(profile_file, "routine: FormatMatrixComp\n");
      if (firsttime)
        fprintf(profile_file, "-----------------------\n");
      if (firsttime)
        fprintf(profile_file, "\n");
      if (firsttime)
        start = clock();
    #endif
       
      // initialize ams structure to zero
      for (nComp = 0; nComp < tempAMSdata.nComp_d; ++nComp) {
        for (i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip; ++i) {
          for (j = 0; j < 10; ++j)
            tempAMSdata.stpDcomp[nComp].fpProps[i][j] = 0;
        }
        for (i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip; ++i) {
          for (j = 0; j < 3; ++j)
            tempAMSdata.stpDcomp[nComp].fpCoords[i][j] = 0;
        }
      }
    
      // loop over all matrices
      for (p = 0; p < *nmat; p++) {
        lpdata.nBalasts = *nrow;
    
        if (*nrow != nrow_old) {
          // free memory allocated for structure in second and third dimension before reallocating first dimension
          for (i = 0; i < nrow_old; ++i) {
            for (j = 0; j < 1; ++j)
              free(lpdata.stBalast[i].lpBalastMatrix[j]);
            free(lpdata.stBalast[i].lpBalastMatrix);
          }
    
          // reallocate structure with new dimensions
          lpdata.stBalast =
              (struct balast_section *) realloc(lpdata.stBalast, sizeof(struct balast_section) * *nrow);
          for (i = 0; i < *nrow; ++i) {
            lpdata.stBalast[i].lpBalastMatrix = (double **) malloc(sizeof(double *) * 1);
            for (j = 0; j < 1; ++j) {
              lpdata.stBalast[i].lpBalastMatrix[j] = (double *) malloc(sizeof(double) * 10);
              for (k = 0; k < 10; ++k) {
                lpdata.stBalast[i].lpBalastMatrix[j][k] = 0;  // initialize values to zero
              }
            }
          }
          // remember old dimensions
          nrow_old = *nrow;
        }
         
        // storage of FORTRAN matrix
       for (k = 0; k < *ncol; k++) {
          for (i = 0; i < *nrow; i++) {
            lpdata.stBalast[i].nRows = 1;
            lpdata.stBalast[i].nColumns = *ncol;
            lpdata.stBalast[i].lpBalastMatrix[0][k] = *(matrix++);
          }
        }
    
        if (!createLPams(cpFileName, &stGeoxData, &stG2SData, &lpdata, &tempAMSdata, comp_flag)) {
          // printf( "\n\ file creation Failed..............\n" ) ;
          // fputs( "\file creation Failed..............", fStream ) ;
        } else {
          // printf( "\ file creation successful..............\n" ) ;
          // fputs( "\ file creation successful..............", fStream ) ;
          LPAMSCreated = 1;
        }
    
        if (LPAMSCreated == 1) {
          // printf( "\ File creation is complete..............\n" ) ;
          // fputs( "\ File creation is complete..........", fStream ) ;
        }
        (comp_flag++);
      }                             // loop over all matrices
    
    #ifdef PROFILE
      if (firsttime)
        finish = clock();
      if (firsttime)
        duration = (double) (finish - start) / CLOCKS_PER_SEC;
      if (firsttime)
        fprintf(profile_file, "create structure:\t\t\t\t\t%8.4f\n", duration);
    #endif
    
      // Write file for validation purposes
      /*********************************************************************/
      /* CREATE MATRIX FROM STRUCTURE ... */
      /*********************************************************************/
      /********************************Processing Files Operation *****************************/
      stReturn = GetOnesMetrixDouble(tempMG1G1.dbpMG1G1_data, tempMG1G1.nRow, tempMG1G1.nColumn, 0);  // initialize tempMG1G1 to zero
    
    #ifdef PROFILE
      if (firsttime)
        start = clock();
    #endif
    
      if (0 == ProcessMatrixData(&stProjectSpace, &tempAMSdata,
                                 &stGeoxData, &stMatrixdata, &stG2SData, &tempMG1G1, fStream)) {
      } else {
        tempMG1G1Created = 1;
        stReturn =
            GetOnesMetrixDouble(stouttempMG1G1->dbpMG1G1_data, stouttempMG1G1->nRow,
                                stouttempMG1G1->nColumn, 0);
        if (0 == ConvertToG1SixMatrix(&tempMG1G1, stouttempMG1G1)) {
          stReturn = 0;
        } else {
          stReturn = 1;
        }
      }
    
    #ifdef PROFILE
      if (firsttime)
        finish = clock();
      if (firsttime)
        duration = (double) (finish - start) / CLOCKS_PER_SEC;
      if (firsttime)
        fprintf(profile_file, "ProcessMatrixData:\t\t\t\t\t\t\t\t%8.4f\n", duration);
    #endif
    
       
      /***************************************************************************************/
      /* MERGE CREATED MATRIX WITH BASE MATRIX TO CREATE TARGET MATRIX ... */
      /***************************************************************************************/
    #ifdef PROFILE
      if (firsttime)
        start = clock();
    #endif
    
      // select target matrix according to value of switch idbaseMat
      switch (*idtargetMat) {
      case OWE_ID:
        ptTargetMat = &stoutMg1g1OWE;
        break;
      case ZFW_ID:
        ptTargetMat = &stMg1g1ZFW;
        break;
      case CS_ID:
        ptTargetMat = &stMg1g1CS;
        break;
      }
      stReturn = GetOnesMetrixDouble(ptBaseMat->dbpMG1G1_data, ptBaseMat->nRow, ptBaseMat->nColumn, 0);
    
      // initialize structure to zero
      // copy values of original baseMat to temporary baseMat container row by row to prevent mixing up of data in the merging process
      // (which matrix to select as baseMat depends on value of input flag idbaseMat)
      for (nRow = 0; nRow < ptBaseMat->nRow; ++nRow) {
        switch (*idbaseMat) {
        case OWE_ID:
          memcpy(ptBaseMat->dbpMG1G1_data[nRow], stoutMg1g1OWE.dbpMG1G1_data[nRow],
                 sizeof(double) * ptBaseMat->nColumn);
          break;
        case ZFW_ID:
          memcpy(ptBaseMat->dbpMG1G1_data[nRow], stMg1g1ZFW.dbpMG1G1_data[nRow],
                 sizeof(double) * ptBaseMat->nColumn);
          break;
        case CS_ID:
          memcpy(ptBaseMat->dbpMG1G1_data[nRow], stMg1g1CS.dbpMG1G1_data[nRow],
                 sizeof(double) * ptBaseMat->nColumn);
          break;
        }
      }
       
      // initialize values of target matrix and cg matrix to zero
      stReturn =
          GetOnesMetrixDouble(ptTargetMat->dbpMG1G1_data, ptTargetMat->nRow, ptTargetMat->nColumn, 0);
      stReturn = GetOnesMetrixDouble(CGMatrix, ptTargetMat->nRow, 3, 0);
    
      // merge created matrix with base matrix to create target matrix
      if (0 == MergeMatrices(ptBaseMat, stouttempMG1G1, &stGeoxData, ptTargetMat, CGMatrix)) {
        stReturn = 0;
      } else {
        stReturn = 1;
      }
    
    #ifdef PROFILE
      if (firsttime)
        finish = clock();
      if (firsttime)
        duration = (double) (finish - start) / CLOCKS_PER_SEC;
      if (firsttime)
        fprintf(profile_file, "merge matrices:\t\t\t\t\t\t\t\t\t%8.4f\n", duration);
    #endif
       
    #ifdef PROFILE
      // close profile
      if (firsttime)
        fclose(profile_file);
    #endif
      if (firsttime)
        firsttime = 0;
    }                               // end of function
    You say the whole lot takes 5 seconds, but how is that broken down?
    fprintf(profile_file, "create structure:\t\t\t\t\t%8.4f\n", duration);
    fprintf(profile_file, "ProcessMatrixData:\t\t\t\t\t\t\t\t%8.4f\n", duration);
    fprintf(profile_file, "merge matrices:\t\t\t\t\t\t\t\t\t%8.4f\n", duration);


    You seem to have lots of arrays with fixed dimensions (3, 10, 1)

    Are all your minor dimensions really compile-time constants?
    If they are, there is significant potential to improve this.
    iMalc and nonpuz like this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,

    Thank you very much for responding, the reply is useful. I will come back to u.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    2 days, and you couldn't even post your timings in that reply....

    Great, I can finish watching my snail racing competition....
    caroundw5h likes this.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,
    please don't finish reading my query!!!!!!!!!!!!
    My Big appology for that. Actually I was unable to access my working machine for past days so I couldn't able to post
    the right relevent content, that is why I replied so. Kindly find the attachment and give your adivce. I have attached the time break down profile.
    Please reply me quickly.



    performance profile
    ------------------------------------------------------

    Time Test mode, step 1 : 0.0940 s
    Time Test mode, step 2 : 0.0310 s
    Time Test mode, step 3 : 0.0310 s
    Time Test mode, step 4 : 0.0470 s
    Time Test mode, step 5 : 0.0310 s
    Time Test mode, step 6 : 0.0320 s
    Time Test mode, step 7 : 0.0460 s
    Time Test mode, step 8 : 0.0320 s
    Time Test mode, step 9 : 0.0310 s
    Time Test mode, step 10 : 0.0310 s
    Time Test mode, step 11 : 0.0470 s
    Time Test mode, step 12 : 0.0310 s
    Time Test mode, step 13 : 0.0320 s
    Time Test mode, step 14 : 0.0460 s
    Time Test mode, step 15 : 0.0320 s
    Time Test mode, step 16 : 0.0310 s
    Time Test mode, step 17 : 0.0310 s
    Time Test mode, step 18 : 0.0470 s
    Time Test mode, step 19 : 0.0310 s
    Time Test mode, step 20 : 0.0320 s
    Time Test mode, step 21 : 0.0310 s
    Time Test mode, step 22 : 0.0470 s
    Time Test mode, step 23 : 0.0310 s
    Time Test mode, step 24 : 0.0310 s
    Time Test mode, step 25 : 0.0470 s
    Time Test mode, step 26 : 0.0310 s
    Time Test mode, step 27 : 0.0320 s
    Time Test mode, step 28 : 0.0310 s
    Time Test mode, step 29 : 0.0470 s
    Time Test mode, step 30 : 0.0310 s
    Time Test mode, step 31 : 0.0310 s
    Time Test mode, step 32 : 0.0470 s
    Time Test mode, step 33 : 0.0310 s
    Time Test mode, step 34 : 0.0320 s
    Time Test mode, step 35 : 0.0310 s
    Time Test mode, step 36 : 0.0470 s
    Time Test mode, step 37 : 0.0310 s
    Time Test mode, step 38 : 0.0310 s
    Time Test mode, step 39 : 0.0470 s
    Time Test mode, step 40 : 0.0310 s
    Time Test mode, step 41 : 0.0320 s
    Time Test mode, step 42 : 0.0310 s
    Time Test mode, step 43 : 0.0470 s
    Time Test mode, step 44 : 0.0310 s
    Time Test mode, step 45 : 0.0310 s
    Time Test mode, step 46 : 0.0310 s
    Time Test mode, step 47 : 0.0470 s
    Time Test mode, step 48 : 0.0320 s
    Time Test mode, step 49 : 0.0460 s
    Time Test mode, step 50 : 0.0320 s
    Time Test mode, step 51 : 0.0310 s
    Time Test mode, step 52 : 0.0470 s
    Time Test mode, step 53 : 0.0310 s
    Time Test mode, step 54 : 0.0310 s
    Time Test mode, step 55 : 0.0320 s
    Time Test mode, step 56 : 0.0460 s
    Time Test mode, step 57 : 0.0320 s
    Time Test mode, step 58 : 0.0310 s
    Time Test mode, step 59 : 0.0470 s
    Time Test mode, step 60 : 0.0310 s
    Time Test mode, step 61 : 0.0310 s
    Time Test mode, step 62 : 0.0320 s
    Time Test mode, step 63 : 0.0460 s
    Time Test mode, step 64 : 0.0320 s
    Time Test mode, step 65 : 0.0310 s
    Time Test mode, step 66 : 0.0310 s
    Time Test mode, step 67 : 0.0470 s
    Time Test mode, step 68 : 0.0310 s
    Time Test mode, step 69 : 0.0320 s
    Time Test mode, step 70 : 0.0460 s
    Time Test mode, step 71 : 0.0320 s
    Time Test mode, step 72 : 0.0310 s
    Time Test mode, step 73 : 0.0470 s
    Time Test mode, step 74 : 0.0310 s
    Time Test mode, step 75 : 0.0310 s
    Time Test mode, step 76 : 0.0320 s
    Time Test mode, step 77 : 0.0460 s
    Time Test mode, step 78 : 0.0320 s
    Time Test mode, step 79 : 0.0310 s
    Time Test mode, step 80 : 0.0470 s
    Time Test mode, step 81 : 0.0310 s
    Time Test mode, step 82 : 0.0310 s
    Time Test mode, step 83 : 0.0320 s
    Time Test mode, step 84 : 0.0460 s
    Time Test mode, step 85 : 0.0320 s
    Time Test mode, step 86 : 0.0310 s
    Time Test mode, step 87 : 0.0470 s
    Time Test mode, step 88 : 0.0310 s
    Time Test mode, step 89 : 0.0310 s
    Time Test mode, step 90 : 0.0320 s
    Time Test mode, step 91 : 0.0460 s
    Time Test mode, step 92 : 0.0320 s
    Time Test mode, step 93 : 0.0310 s
    Time Test mode, step 94 : 0.0470 s
    Time Test mode, step 95 : 0.0310 s
    Time Test mode, step 96 : 0.0310 s
    Time Test mode, step 97 : 0.0470 s
    Time Test mode, step 98 : 0.0310 s
    Time Test mode, step 99 : 0.0320 s
    Time Test mode, step 100 : 0.0310 s
    Time Test mode, step 101 : 0.0470 s
    Time Test mode, step 102 : 0.0310 s
    Time Test mode, step 103 : 0.0310 s
    Time Test mode, step 104 : 0.0470 s
    Time Test mode, step 105 : 0.0310 s
    Time Test mode, step 106 : 0.0320 s
    Time Test mode, step 107 : 0.0310 s
    Time Test mode, step 108 : 0.0470 s
    Time Test mode, step 109 : 0.0310 s
    Time Test mode, step 110 : 0.0310 s
    Time Test mode, step 111 : 0.0470 s
    Time Test mode, step 112 : 0.0310 s
    Time Test mode, step 113 : 0.0320 s
    Time Test mode, step 114 : 0.0310 s
    Time Test mode, step 115 : 0.0470 s
    Time Test mode, step 116 : 0.0310 s
    Time Test mode, step 117 : 0.0310 s
    Time Test mode, step 118 : 0.0470 s
    Time Test mode, step 119 : 0.0310 s
    Time Test mode, step 120 : 0.0320 s
    Time Test mode, step 121 : 0.0310 s
    Time Test mode, step 122 : 0.0470 s
    Time Test mode, step 123 : 0.0310 s
    Time Test mode, step 124 : 0.0310 s
    Time Test mode, step 125 : 0.0470 s
    Time Test mode, step 126 : 0.0310 s
    Time Test mode, step 127 : 0.0320 s
    Time Test mode, step 128 : 0.0310 s
    Time Test mode, step 129 : 0.0470 s
    Time Test mode, step 130 : 0.0310 s
    Time Test mode, step 131 : 0.0310 s
    Time Test mode, step 132 : 0.0470 s
    Time Test mode, step 133 : 0.0310 s
    Time Test mode, step 134 : 0.0320 s
    Time Test mode, step 135 : 0.0470 s
    Time Test mode, step 136 : 0.0310 s
    Time Test mode, step 137 : 0.0310 s
    Time Test mode, step 138 : 0.0470 s
    Time Test mode, step 139 : 0.0310 s
    Time Test mode, step 140 : 0.0310 s
    Time Test mode, step 141 : 0.0320 s
    Time Test mode, step 142 : 0.0470 s
    Time Test mode, step 143 : 0.0310 s
    Time Test mode, step 144 : 0.0310 s
    Time Test mode, step 145 : 0.0470 s
    Time Test mode, step 146 : 0.0310 s
    Time Test mode, step 147 : 0.0310 s
    Time Test mode, step 148 : 0.0320 s
    Time Test mode, step 149 : 0.0470 s
    Time Test mode, step 150 : 0.0310 s
    Time Test mode, step 151 : 0.0310 s
    Time Test mode, step 152 : 0.0470 s
    Time Test mode, step 153 : 0.0310 s
    Time Test mode, step 154 : 0.0310 s
    Time Test mode, step 155 : 0.0320 s
    Time Test mode, step 156 : 0.0470 s
    Time Test mode, step 157 : 0.0310 s
    Time Test mode, step 158 : 0.0310 s
    Time Test mode, step 159 : 0.0470 s
    Time Test mode, step 160 : 0.0310 s
    Time Test mode, step 161 : 0.0310 s
    Time Test mode, step 162 : 0.0320 s
    Time Test mode, step 163 : 0.0470 s
    Time Test mode, step 164 : 0.0310 s
    Time Test mode, step 165 : 0.0310 s
    Time Test mode, step 166 : 0.0470 s
    Time Test mode, step 167 : 0.0310 s
    Time Test mode, step 168 : 0.0310 s
    Time Test mode, step 169 : 0.0470 s
    Time Test mode, step 170 : 0.0320 s
    Time Test mode, step 171 : 0.0310 s
    Time Test mode, step 172 : 0.0470 s
    Time Test mode, step 173 : 0.0310 s
    Time Test mode, step 174 : 0.0310 s
    Time Test mode, step 175 : 0.0470 s
    Time Test mode, step 176 : 0.0310 s
    Time Test mode, step 177 : 0.0320 s
    Time Test mode, step 178 : 0.0460 s
    Time Test mode, step 179 : 0.0320 s
    Time Test mode, step 180 : 0.0310 s
    Time Test mode, step 181 : 0.0310 s
    Time Test mode, step 182 : 0.0470 s
    Time Test mode, step 183 : 0.0310 s
    Time Test mode, step 184 : 0.0320 s
    Time Test mode, step 185 : 0.0460 s
    Time Test mode, step 186 : 0.0320 s
    Time Test mode, step 187 : 0.0310 s
    Time Test mode, step 188 : 0.0310 s
    Time Test mode, step 189 : 0.0470 s
    Time Test mode, step 190 : 0.0310 s
    Time Test mode, step 191 : 0.0320 s
    Time Test mode, step 192 : 0.0460 s
    Time Test mode, step 193 : 0.0320 s
    Time Test mode, step 194 : 0.0310 s
    Time Test mode, step 195 : 0.0470 s
    Time Test mode, step 196 : 0.0310 s
    Time Test mode, step 197 : 0.0310 s
    Time Test mode, step 198 : 0.0320 s
    Time Test mode, step 199 : 0.0460 s
    Time Test mode, step 200 : 0.0320 s
    Time Test mode, step 201 : 0.0310 s
    Time Test mode, step 202 : 0.0470 s
    Time Test mode, step 203 : 0.0310 s
    Time Test mode, step 204 : 0.0310 s
    Time Test mode, step 205 : 0.0320 s
    Time Test mode, step 206 : 0.0460 s
    Time Test mode, step 207 : 0.0320 s
    Time Test mode, step 208 : 0.0310 s
    Time Test mode, step 209 : 0.0470 s
    Time Test mode, step 210 : 0.0310 s
    Time Test mode, step 211 : 0.0310 s
    Time Test mode, step 212 : 0.0470 s
    Time Test mode, step 213 : 0.0320 s
    Time Test mode, step 214 : 0.0310 s
    Time Test mode, step 215 : 0.0310 s
    Time Test mode, step 216 : 0.0470 s
    Time Test mode, step 217 : 0.0310 s
    Time Test mode, step 218 : 0.0310 s
    Time Test mode, step 219 : 0.0470 s
    Time Test mode, step 220 : 0.0320 s
    Time Test mode, step 221 : 0.0310 s
    Time Test mode, step 222 : 0.0310 s
    Time Test mode, step 223 : 0.0470 s
    Time Test mode, step 224 : 0.0310 s
    Time Test mode, step 225 : 0.0310 s
    Time Test mode, step 226 : 0.0470 s
    Time Test mode, step 227 : 0.0320 s
    Time Test mode, step 228 : 0.0310 s
    Time Test mode, step 229 : 0.0470 s
    Time Test mode, step 230 : 0.0310 s
    Time Test mode, step 231 : 0.0310 s
    Time Test mode, step 232 : 0.0470 s
    Time Test mode, step 233 : 0.0310 s
    Time Test mode, step 234 : 0.0320 s
    Time Test mode, step 235 : 0.0460 s
    Time Test mode, step 236 : 0.0320 s
    Time Test mode, step 237 : 0.0310 s
    Time Test mode, step 238 : 0.0310 s
    Time Test mode, step 239 : 0.0470 s
    Time Test mode, step 240 : 0.0310 s
    Time Test mode, step 241 : 0.0320 s
    Time Test mode, step 242 : 0.0460 s
    Time Test mode, step 243 : 0.0320 s
    Time Test mode, step 244 : 0.0310 s
    Time Test mode, step 245 : 0.0310 s
    Time Test mode, step 246 : 0.0470 s
    Time Test mode, step 247 : 0.0310 s
    Time Test mode, step 248 : 0.0320 s
    Time Test mode, step 249 : 0.0460 s
    Time Test mode, step 250 : 0.0320 s
    Time Test mode, step 251 : 0.0310 s
    Time Test mode, step 252 : 0.0310 s
    Time Test mode, step 253 : 0.0470 s
    Time Test mode, step 254 : 0.0310 s
    Time Test mode, step 255 : 0.0320 s
    Time Test mode, step 256 : 0.0460 s
    Time Test mode, step 257 : 0.0320 s
    Time Test mode, step 258 : 0.0310 s
    Time Test mode, step 259 : 0.0310 s
    Time Test mode, step 260 : 0.0470 s
    Time Test mode, step 261 : 0.0310 s
    Time Test mode, step 262 : 0.0320 s
    Time Test mode, step 263 : 0.0460 s
    Time Test mode, step 264 : 0.0320 s
    Time Test mode, step 265 : 0.0310 s
    Time Test mode, step 266 : 0.0310 s
    Time Test mode, step 267 : 0.0470 s
    Time Test mode, step 268 : 0.0310 s
    Time Test mode, step 269 : 0.0320 s
    Time Test mode, step 270 : 0.0460 s
    Time Test mode, step 271 : 0.0320 s
    Time Test mode, step 272 : 0.0310 s
    Time Test mode, step 273 : 0.0310 s
    Time Test mode, step 274 : 0.0470 s
    Time Test mode, step 275 : 0.0310 s
    Time Test mode, step 276 : 0.0320 s
    Time Test mode, step 277 : 0.0460 s
    Time Test mode, step 278 : 0.0320 s
    Time Test mode, step 279 : 0.0310 s
    Time Test mode, step 280 : 0.0310 s
    Time Test mode, step 281 : 0.0470 s
    Time Test mode, step 282 : 0.0310 s
    Time Test mode, step 283 : 0.0320 s
    Time Test mode, step 284 : 0.0460 s
    Time Test mode, step 285 : 0.0320 s
    Time Test mode, step 286 : 0.0310 s
    Time Test mode, step 287 : 0.0470 s
    Time Test mode, step 288 : 0.0310 s
    Time Test mode, step 289 : 0.0310 s
    Time Test mode, step 290 : 0.0320 s
    Time Test mode, step 291 : 0.0460 s
    Time Test mode, step 292 : 0.0320 s
    Time Test mode, step 293 : 0.0310 s
    Time Test mode, step 294 : 0.0470 s
    Time Test mode, step 295 : 0.0310 s
    Time Test mode, step 296 : 0.0310 s
    Time Test mode, step 297 : 0.0320 s
    Time Test mode, step 298 : 0.0460 s
    Time Test mode, step 299 : 0.0320 s
    Time Test mode, step 300 : 0.0310 s
    Time Test mode, step 301 : 0.0470 s
    Time Test mode, step 302 : 0.0310 s
    Time Test mode, step 303 : 0.0310 s
    Time Test mode, step 304 : 0.0320 s
    Time Test mode, step 305 : 0.0460 s
    Time Test mode, step 306 : 0.0320 s
    Time Test mode, step 307 : 0.0310 s
    Time Test mode, step 308 : 0.0470 s
    Time Test mode, step 309 : 0.0310 s
    Time Test mode, step 310 : 0.0310 s
    Time Test mode, step 311 : 0.0320 s
    Time Test mode, step 312 : 0.0460 s
    Time Test mode, step 313 : 0.0320 s
    Time Test mode, step 314 : 0.0310 s
    Time Test mode, step 315 : 0.0470 s
    Time Test mode, step 316 : 0.0310 s
    Time Test mode, step 317 : 0.0310 s
    Time Test mode, step 318 : 0.0320 s
    Time Test mode, step 319 : 0.0460 s
    Time Test mode, step 320 : 0.0320 s
    Time Test mode, step 321 : 0.0310 s
    Time Test mode, step 322 : 0.0470 s
    Time Test mode, step 323 : 0.0310 s
    Time Test mode, step 324 : 0.0310 s
    Time Test mode, step 325 : 0.0320 s
    Time Test mode, step 326 : 0.0460 s
    Time Test mode, step 327 : 0.0320 s
    Time Test mode, step 328 : 0.0310 s
    Time Test mode, step 329 : 0.0470 s
    Time Test mode, step 330 : 0.0310 s
    Time Test mode, step 331 : 0.0310 s
    Time Test mode, step 332 : 0.0320 s
    Time Test mode, step 333 : 0.0460 s
    Time Test mode, step 334 : 0.0320 s
    Time Test mode, step 335 : 0.0310 s
    Time Test mode, step 336 : 0.0470 s
    Time Test mode, step 337 : 0.0310 s
    Time Test mode, step 338 : 0.0310 s
    Time Test mode, step 339 : 0.0320 s
    Time Test mode, step 340 : 0.0460 s
    Time Test mode, step 341 : 0.0320 s
    Time Test mode, step 342 : 0.0310 s
    Time Test mode, step 343 : 0.0470 s
    Time Test mode, step 344 : 0.0310 s
    Time Test mode, step 345 : 0.0310 s
    Time Test mode, step 346 : 0.0470 s
    Time Test mode, step 347 : 0.0310 s
    Time Test mode, step 348 : 0.0320 s
    Time Test mode, step 349 : 0.0310 s
    Time Test mode, step 350 : 0.0470 s
    Time Test mode, step 351 : 0.0310 s
    Time Test mode, step 352 : 0.0310 s
    Time Test mode, step 353 : 0.0470 s
    Time Test mode, step 354 : 0.0310 s
    Time Test mode, step 355 : 0.0320 s
    Time Test mode, step 356 : 0.0310 s
    Time Test mode, step 357 : 0.0470 s
    Time Test mode, step 358 : 0.0310 s
    Time Test mode, step 359 : 0.0310 s
    Time Test mode, step 360 : 0.0470 s
    Time Test mode, step 361 : 0.0310 s
    Time Test mode, step 362 : 0.0320 s
    Time Test mode, step 363 : 0.0310 s
    Time Test mode, step 364 : 0.0470 s
    Time Test mode, step 365 : 0.0310 s
    Time Test mode, step 366 : 0.0310 s
    Time Test mode, step 367 : 0.0470 s
    Time Test mode, step 368 : 0.0310 s
    Time Test mode, step 369 : 0.0320 s
    Time Test mode, step 370 : 0.0310 s
    Time Test mode, step 371 : 0.0470 s
    Time Test mode, step 372 : 0.0310 s
    Time Test mode, step 373 : 0.0310 s
    Time Test mode, step 374 : 0.0470 s
    Time Test mode, step 375 : 0.0310 s
    Time Test mode, step 376 : 0.0320 s
    Time Test mode, step 377 : 0.0310 s
    Time Test mode, step 378 : 0.0470 s
    Time Test mode, step 379 : 0.0310 s
    Time Test mode, step 380 : 0.0310 s
    Time Test mode, step 381 : 0.0470 s
    Time Test mode, step 382 : 0.0310 s
    Time Test mode, step 383 : 0.0320 s
    Time Test mode, step 384 : 0.0310 s
    Time Test mode, step 385 : 0.0470 s
    Time Test mode, step 386 : 0.0310 s
    Time Test mode, step 387 : 0.0310 s
    Time Test mode, step 388 : 0.0470 s
    Time Test mode, step 389 : 0.0310 s
    Time Test mode, step 390 : 0.0320 s
    Time Test mode, step 391 : 0.0470 s
    Time Test mode, step 392 : 0.0310 s
    Time Test mode, step 393 : 0.0310 s
    Time Test mode, step 394 : 0.0310 s
    Time Test mode, step 395 : 0.0470 s
    Time Test mode, step 396 : 0.0310 s
    Time Test mode, step 397 : 0.0320 s
    Time Test mode, step 398 : 0.0470 s
    Time Test mode, step 399 : 0.0310 s
    Time Test mode, step 400 : 0.0310 s
    Time Test mode, step 401 : 0.0310 s
    Time Test mode, step 402 : 0.0470 s
    Time Test mode, step 403 : 0.0310 s
    Time Test mode, step 404 : 0.0320 s
    Time Test mode, step 405 : 0.0470 s
    Time Test mode, step 406 : 0.0310 s
    Time Test mode, step 407 : 0.0310 s
    Time Test mode, step 408 : 0.0310 s
    Time Test mode, step 409 : 0.0470 s
    Time Test mode, step 410 : 0.0310 s
    Time Test mode, step 411 : 0.0320 s
    Time Test mode, step 412 : 0.0470 s
    Time Test mode, step 413 : 0.0310 s
    Time Test mode, step 414 : 0.0310 s
    Time Test mode, step 415 : 0.0470 s
    Time Test mode, step 416 : 0.0310 s
    Time Test mode, step 417 : 0.0310 s
    Time Test mode, step 418 : 0.0470 s
    Time Test mode, step 419 : 0.0320 s
    Time Test mode, step 420 : 0.0310 s
    Time Test mode, step 421 : 0.0310 s
    Time Test mode, step 422 : 0.0470 s
    Time Test mode, step 423 : 0.0310 s
    Time Test mode, step 424 : 0.0310 s
    Time Test mode, step 425 : 0.0470 s
    Time Test mode, step 426 : 0.0320 s
    Time Test mode, step 427 : 0.0310 s
    Time Test mode, step 428 : 0.0470 s
    Time Test mode, step 429 : 0.0310 s
    Time Test mode, step 430 : 0.0310 s
    Time Test mode, step 431 : 0.0470 s
    Time Test mode, step 432 : 0.0310 s
    Time Test mode, step 433 : 0.0320 s
    Time Test mode, step 434 : 0.0460 s
    Time Test mode, step 435 : 0.0320 s
    Time Test mode, step 436 : 0.0310 s
    Time Test mode, step 437 : 0.0470 s
    Time Test mode, step 438 : 0.0310 s
    Time Test mode, step 439 : 0.0310 s
    Time Test mode, step 440 : 0.0320 s
    Time Test mode, step 441 : 0.0460 s
    Time Test mode, step 442 : 0.0320 s
    Time Test mode, step 443 : 0.0310 s
    Time Test mode, step 444 : 0.0470 s
    Time Test mode, step 445 : 0.0310 s
    Time Test mode, step 446 : 0.0310 s
    Time Test mode, step 447 : 0.0470 s
    Time Test mode, step 448 : 0.0310 s
    Time Test mode, step 449 : 0.0320 s
    Time Test mode, step 450 : 0.0470 s
    Time Test mode, step 451 : 0.0310 s
    Time Test mode, step 452 : 0.0310 s
    Time Test mode, step 453 : 0.0310 s
    Time Test mode, step 454 : 0.0470 s
    Time Test mode, step 455 : 0.0310 s
    Time Test mode, step 456 : 0.0320 s
    Time Test mode, step 457 : 0.0470 s
    Time Test mode, step 458 : 0.0310 s
    Time Test mode, step 459 : 0.0310 s
    Time Test mode, step 460 : 0.0310 s
    Time Test mode, step 461 : 0.0470 s
    Time Test mode, step 462 : 0.0310 s
    Time Test mode, step 463 : 0.0320 s
    Time Test mode, step 464 : 0.0470 s
    Time Test mode, step 465 : 0.0310 s
    Time Test mode, step 466 : 0.0310 s
    Time Test mode, step 467 : 0.0470 s
    Time Test mode, step 468 : 0.0310 s
    Time Test mode, step 469 : 0.0310 s
    Time Test mode, step 470 : 0.0470 s
    Time Test mode, step 471 : 0.0320 s
    Time Test mode, step 472 : 0.0310 s
    Time Test mode, step 473 : 0.0620 s
    Time Test mode, step 474 : 0.0320 s
    Time Test mode, step 475 : 0.0460 s
    Time Test mode, step 476 : 0.0320 s
    Time Test mode, step 477 : 0.0310 s
    Time Test mode, step 478 : 0.0310 s
    Time Test mode, step 479 : 0.0470 s
    Time Test mode, step 480 : 0.0310 s
    Time Test mode, step 481 : 0.0320 s
    Time Test mode, step 482 : 0.0460 s
    Time Test mode, step 483 : 0.0320 s
    Time Test mode, step 484 : 0.0310 s
    Time Test mode, step 485 : 0.0470 s
    Time Test mode, step 486 : 0.0310 s
    Time Test mode, step 487 : 0.0310 s
    Time Test mode, step 488 : 0.0320 s
    Time Test mode, step 489 : 0.0460 s
    Time Test mode, step 490 : 0.0320 s
    Time Test mode, step 491 : 0.0310 s
    Time Test mode, step 492 : 0.0470 s
    Time Test mode, step 493 : 0.0310 s
    Time Test mode, step 494 : 0.0310 s
    Time Test mode, step 495 : 0.0470 s
    Time Test mode, step 496 : 0.0310 s
    Time Test mode, step 497 : 0.0320 s
    Time Test mode, step 498 : 0.0470 s
    Time Test mode, step 499 : 0.0310 s
    Time Test mode, step 500 : 0.0310 s
    Time Test mode, step 501 : 0.0310 s
    Time Test mode, step 502 : 0.0470 s
    Time Test mode, step 503 : 0.0310 s
    Time Test mode, step 504 : 0.0320 s
    Time Test mode, step 505 : 0.0470 s
    Time Test mode, step 506 : 0.0310 s
    Time Test mode, step 507 : 0.0310 s
    Time Test mode, step 508 : 0.0470 s
    Time Test mode, step 509 : 0.0310 s
    Time Test mode, step 510 : 0.0310 s
    Time Test mode, step 511 : 0.0470 s
    Time Test mode, step 512 : 0.0320 s
    Time Test mode, step 513 : 0.0460 s
    Time Test mode, step 514 : 0.0320 s
    Time Test mode, step 515 : 0.0470 s
    Time Test mode, step 516 : 0.0310 s
    Time Test mode, step 517 : 0.0310 s
    Time Test mode, step 518 : 0.0310 s
    Time Test mode, step 519 : 0.0470 s
    Time Test mode, step 520 : 0.0310 s
    Time Test mode, step 521 : 0.0320 s
    Time Test mode, step 522 : 0.0470 s
    Time Test mode, step 523 : 0.0310 s
    Time Test mode, step 524 : 0.0310 s
    Time Test mode, step 525 : 0.0470 s
    Time Test mode, step 526 : 0.0310 s
    Time Test mode, step 527 : 0.0310 s
    Time Test mode, step 528 : 0.0320 s
    Time Test mode, step 529 : 0.0470 s
    Time Test mode, step 530 : 0.0310 s
    Time Test mode, step 531 : 0.0470 s
    Time Test mode, step 532 : 0.0310 s
    Time Test mode, step 533 : 0.0310 s
    Time Test mode, step 534 : 0.0310 s
    Time Test mode, step 535 : 0.0470 s
    Time Test mode, step 536 : 0.0320 s
    Time Test mode, step 537 : 0.0310 s
    Time Test mode, step 538 : 0.0470 s
    Time Test mode, step 539 : 0.0310 s
    Time Test mode, step 540 : 0.0310 s
    Time Test mode, step 541 : 0.0470 s
    Time Test mode, step 542 : 0.0310 s
    Time Test mode, step 543 : 0.0320 s
    Time Test mode, step 544 : 0.0460 s
    Time Test mode, step 545 : 0.0320 s
    Time Test mode, step 546 : 0.0310 s
    Time Test mode, step 547 : 0.0310 s
    Time Test mode, step 548 : 0.0470 s
    Time Test mode, step 549 : 0.0310 s
    Time Test mode, step 550 : 0.0320 s
    Time Test mode, step 551 : 0.0460 s
    Time Test mode, step 552 : 0.0320 s
    Time Test mode, step 553 : 0.0310 s
    Time Test mode, step 554 : 0.0310 s
    Time Test mode, step 555 : 0.0470 s
    Time Test mode, step 556 : 0.0310 s
    Time Test mode, step 557 : 0.0320 s
    Time Test mode, step 558 : 0.0460 s
    Time Test mode, step 559 : 0.0320 s
    Time Test mode, step 560 : 0.0310 s
    Time Test mode, step 561 : 0.0310 s
    Time Test mode, step 562 : 0.0470 s
    Time Test mode, step 563 : 0.0310 s
    Time Test mode, step 564 : 0.0320 s
    Time Test mode, step 565 : 0.0460 s
    Time Test mode, step 566 : 0.0320 s
    Time Test mode, step 567 : 0.0310 s
    Time Test mode, step 568 : 0.0310 s
    Time Test mode, step 569 : 0.0470 s
    Time Test mode, step 570 : 0.0310 s
    Time Test mode, step 571 : 0.0320 s
    Time Test mode, step 572 : 0.0460 s
    Time Test mode, step 573 : 0.0320 s
    Time Test mode, step 574 : 0.0310 s
    Time Test mode, step 575 : 0.0470 s
    Time Test mode, step 576 : 0.0310 s
    Time Test mode, step 577 : 0.0310 s
    Time Test mode, step 578 : 0.0320 s
    Time Test mode, step 579 : 0.0460 s
    Time Test mode, step 580 : 0.0320 s
    Time Test mode, step 581 : 0.0310 s
    Time Test mode, step 582 : 0.0470 s
    Time Test mode, step 583 : 0.0310 s
    Time Test mode, step 584 : 0.0310 s
    Time Test mode, step 585 : 0.0320 s
    Time Test mode, step 586 : 0.0460 s
    Time Test mode, step 587 : 0.0320 s
    Time Test mode, step 588 : 0.0310 s
    Time Test mode, step 589 : 0.0470 s
    Time Test mode, step 590 : 0.0310 s
    Time Test mode, step 591 : 0.0310 s
    Time Test mode, step 592 : 0.0470 s
    Time Test mode, step 593 : 0.0310 s
    Time Test mode, step 594 : 0.0320 s
    Time Test mode, step 595 : 0.0310 s
    Time Test mode, step 596 : 0.0470 s
    Time Test mode, step 597 : 0.0310 s
    Time Test mode, step 598 : 0.0310 s
    Time Test mode, step 599 : 0.0470 s
    Time Test mode, step 600 : 0.0310 s
    Time Test mode, step 601 : 0.0320 s
    Time Test mode, step 602 : 0.0310 s
    Time Test mode, step 603 : 0.0470 s
    Time Test mode, step 604 : 0.0310 s
    Time Test mode, step 605 : 0.0310 s
    Time Test mode, step 606 : 0.0470 s
    Time Test mode, step 607 : 0.0310 s
    Time Test mode, step 608 : 0.0320 s
    Time Test mode, step 609 : 0.0310 s
    Time Test mode, step 610 : 0.0470 s
    Time Test mode, step 611 : 0.0310 s
    Time Test mode, step 612 : 0.0310 s
    Time Test mode, step 613 : 0.0320 s
    Time Test mode, step 614 : 0.0460 s
    Time Test mode, step 615 : 0.0320 s
    Time Test mode, step 616 : 0.0310 s
    Time Test mode, step 617 : 0.0470 s
    Time Test mode, step 618 : 0.0310 s
    Time Test mode, step 619 : 0.0310 s
    Time Test mode, step 620 : 0.0470 s
    Time Test mode, step 621 : 0.0310 s
    Time Test mode, step 622 : 0.0320 s
    Time Test mode, step 623 : 0.0310 s
    Time Test mode, step 624 : 0.0470 s
    Time Test mode, step 625 : 0.0310 s
    Time Test mode, step 626 : 0.0310 s
    Time Test mode, step 627 : 0.0320 s
    Time Test mode, step 628 : 0.0460 s
    Time Test mode, step 629 : 0.0320 s
    Time Test mode, step 630 : 0.0470 s
    Time Test mode, step 631 : 0.0310 s
    Time Test mode, step 632 : 0.0310 s
    Time Test mode, step 633 : 0.0310 s
    Time Test mode, step 634 : 0.0470 s
    Time Test mode, step 635 : 0.0310 s
    Time Test mode, step 636 : 0.0320 s
    Time Test mode, step 637 : 0.0310 s
    Time Test mode, step 638 : 0.0470 s
    Time Test mode, step 639 : 0.0310 s
    Time Test mode, step 640 : 0.0310 s
    Time Test mode, step 641 : 0.0470 s
    Time Test mode, step 642 : 0.0310 s
    Time Test mode, step 643 : 0.0320 s
    Time Test mode, step 644 : 0.0310 s
    Time Test mode, step 645 : 0.0470 s
    Time Test mode, step 646 : 0.0310 s
    Time Test mode, step 647 : 0.0310 s
    Time Test mode, step 648 : 0.0470 s
    Time Test mode, step 649 : 0.0310 s
    Time Test mode, step 650 : 0.0320 s
    Time Test mode, step 651 : 0.0470 s
    Time Test mode, step 652 : 0.0310 s
    Time Test mode, step 653 : 0.0310 s
    Time Test mode, step 654 : 0.0310 s
    Time Test mode, step 655 : 0.0470 s
    Time Test mode, step 656 : 0.0310 s
    Time Test mode, step 657 : 0.0320 s
    Time Test mode, step 658 : 0.0310 s
    Time Test mode, step 659 : 0.0470 s
    Time Test mode, step 660 : 0.0310 s
    Time Test mode, step 661 : 0.0310 s
    Time Test mode, step 662 : 0.0470 s
    Time Test mode, step 663 : 0.0310 s
    Time Test mode, step 664 : 0.0320 s
    Time Test mode, step 665 : 0.0310 s
    Time Test mode, step 666 : 0.0470 s
    Time Test mode, step 667 : 0.0310 s
    Time Test mode, step 668 : 0.0310 s
    Time Test mode, step 669 : 0.0470 s
    Time Test mode, step 670 : 0.0310 s
    Time Test mode, step 671 : 0.0320 s
    Time Test mode, step 672 : 0.0310 s
    Time Test mode, step 673 : 0.0470 s
    Time Test mode, step 674 : 0.0310 s
    Time Test mode, step 675 : 0.0310 s
    Time Test mode, step 676 : 0.0470 s
    Time Test mode, step 677 : 0.0310 s
    Time Test mode, step 678 : 0.0320 s
    Time Test mode, step 679 : 0.0310 s
    Time Test mode, step 680 : 0.0470 s
    Time Test mode, step 681 : 0.0310 s
    Time Test mode, step 682 : 0.0310 s
    Time Test mode, step 683 : 0.0470 s
    Time Test mode, step 684 : 0.0310 s
    Time Test mode, step 685 : 0.0320 s
    Time Test mode, step 686 : 0.0310 s
    Time Test mode, step 687 : 0.0470 s
    Time Test mode, step 688 : 0.0310 s
    Time Test mode, step 689 : 0.0310 s
    Time Test mode, step 690 : 0.0470 s
    Time Test mode, step 691 : 0.0310 s
    Time Test mode, step 692 : 0.0320 s
    Time Test mode, step 693 : 0.0310 s
    Time Test mode, step 694 : 0.0470 s
    Time Test mode, step 695 : 0.0310 s
    Time Test mode, step 696 : 0.0310 s
    Time Test mode, step 697 : 0.0470 s
    Time Test mode, step 698 : 0.0310 s
    Time Test mode, step 699 : 0.0320 s
    Time Test mode, step 700 : 0.0470 s
    Time Test mode, step 701 : 0.0310 s
    Time Test mode, step 702 : 0.0310 s
    Time Test mode, step 703 : 0.0310 s
    Time Test mode, step 704 : 0.0470 s
    Time Test mode, step 705 : 0.0310 s
    Time Test mode, step 706 : 0.0320 s
    Time Test mode, step 707 : 0.0470 s
    Time Test mode, step 708 : 0.0310 s
    Time Test mode, step 709 : 0.0310 s
    Time Test mode, step 710 : 0.0310 s
    Time Test mode, step 711 : 0.0470 s
    Time Test mode, step 712 : 0.0310 s
    Time Test mode, step 713 : 0.0320 s
    Time Test mode, step 714 : 0.0470 s
    Time Test mode, step 715 : 0.0310 s
    Time Test mode, step 716 : 0.0310 s
    Time Test mode, step 717 : 0.0470 s
    Time Test mode, step 718 : 0.0310 s
    Time Test mode, step 719 : 0.0310 s
    Time Test mode, step 720 : 0.0320 s
    Time Test mode, step 721 : 0.0470 s
    Time Test mode, step 722 : 0.0310 s
    Time Test mode, step 723 : 0.0310 s
    Time Test mode, step 724 : 0.0470 s
    Time Test mode, step 725 : 0.0310 s
    Time Test mode, step 726 : 0.0310 s
    Time Test mode, step 727 : 0.0320 s
    Time Test mode, step 728 : 0.0470 s
    Time Test mode, step 729 : 0.0310 s
    Time Test mode, step 730 : 0.0310 s
    Time Test mode, step 731 : 0.0470 s
    Time Test mode, step 732 : 0.0310 s
    Time Test mode, step 733 : 0.0310 s
    Time Test mode, step 734 : 0.0470 s
    Time Test mode, step 735 : 0.0320 s
    Time Test mode, step 736 : 0.0310 s
    Time Test mode, step 737 : 0.0310 s
    Time Test mode, step 738 : 0.0470 s
    Time Test mode, step 739 : 0.0310 s
    Time Test mode, step 740 : 0.0310 s
    Time Test mode, step 741 : 0.0470 s
    Time Test mode, step 742 : 0.0320 s
    Time Test mode, step 743 : 0.0310 s
    Time Test mode, step 744 : 0.0310 s
    Time Test mode, step 745 : 0.0470 s
    Time Test mode, step 746 : 0.0310 s
    Time Test mode, step 747 : 0.0310 s
    Time Test mode, step 748 : 0.0470 s
    Time Test mode, step 749 : 0.0320 s
    Time Test mode, step 750 : 0.0310 s
    Time Test mode, step 751 : 0.0310 s
    Time Test mode, step 752 : 0.0470 s
    Time Test mode, step 753 : 0.0310 s
    Time Test mode, step 754 : 0.0320 s
    Time Test mode, step 755 : 0.0460 s
    Time Test mode, step 756 : 0.0320 s
    Time Test mode, step 757 : 0.0310 s
    Time Test mode, step 758 : 0.0310 s
    Time Test mode, step 759 : 0.0470 s
    Time Test mode, step 760 : 0.0310 s
    Time Test mode, step 761 : 0.0320 s
    Time Test mode, step 762 : 0.0460 s
    Time Test mode, step 763 : 0.0320 s
    Time Test mode, step 764 : 0.0310 s
    Time Test mode, step 765 : 0.0310 s
    Time Test mode, step 766 : 0.0470 s
    Time Test mode, step 767 : 0.0310 s
    Time Test mode, step 768 : 0.0320 s
    Time Test mode, step 769 : 0.0460 s
    Time Test mode, step 770 : 0.0320 s
    Time Test mode, step 771 : 0.0310 s
    Time Test mode, step 772 : 0.0470 s
    Time Test mode, step 773 : 0.0310 s
    Time Test mode, step 774 : 0.0310 s
    Time Test mode, step 775 : 0.0320 s
    Time Test mode, step 776 : 0.0460 s
    Time Test mode, step 777 : 0.0320 s
    Time Test mode, step 778 : 0.0310 s
    Time Test mode, step 779 : 0.0470 s
    Time Test mode, step 780 : 0.0310 s
    Time Test mode, step 781 : 0.0310 s
    Time Test mode, step 782 : 0.0320 s
    Time Test mode, step 783 : 0.0460 s
    Time Test mode, step 784 : 0.0320 s
    Time Test mode, step 785 : 0.0310 s
    Time Test mode, step 786 : 0.0470 s
    Time Test mode, step 787 : 0.0310 s
    Time Test mode, step 788 : 0.0310 s
    Time Test mode, step 789 : 0.0320 s
    Time Test mode, step 790 : 0.0460 s
    Time Test mode, step 791 : 0.0320 s
    Time Test mode, step 792 : 0.0310 s
    Time Test mode, step 793 : 0.0470 s
    Time Test mode, step 794 : 0.0310 s
    Time Test mode, step 795 : 0.0310 s
    Time Test mode, step 796 : 0.0320 s
    Time Test mode, step 797 : 0.0460 s
    Time Test mode, step 798 : 0.0320 s
    Time Test mode, step 799 : 0.0310 s
    Time Test mode, step 800 : 0.0470 s
    Time Test mode, step 801 : 0.0310 s
    Time Test mode, step 802 : 0.0310 s
    Time Test mode, step 803 : 0.0470 s
    Time Test mode, step 804 : 0.0310 s
    Time Test mode, step 805 : 0.0320 s
    Time Test mode, step 806 : 0.0310 s
    Time Test mode, step 807 : 0.0470 s
    Time Test mode, step 808 : 0.0310 s
    Time Test mode, step 809 : 0.0310 s
    Time Test mode, step 810 : 0.0320 s
    Time Test mode, step 811 : 0.0460 s
    Time Test mode, step 812 : 0.0320 s
    Time Test mode, step 813 : 0.0310 s
    Time Test mode, step 814 : 0.0470 s
    Time Test mode, step 815 : 0.0310 s
    Time Test mode, step 816 : 0.0310 s
    Time Test mode, step 817 : 0.0470 s
    Time Test mode, step 818 : 0.0310 s
    Time Test mode, step 819 : 0.0320 s
    Time Test mode, step 820 : 0.0310 s
    Time Test mode, step 821 : 0.0470 s
    Time Test mode, step 822 : 0.0310 s
    Time Test mode, step 823 : 0.0310 s
    Time Test mode, step 824 : 0.0470 s
    Time Test mode, step 825 : 0.0310 s
    Time Test mode, step 826 : 0.0320 s
    Time Test mode, step 827 : 0.0310 s
    Time Test mode, step 828 : 0.0470 s
    Time Test mode, step 829 : 0.0310 s
    Time Test mode, step 830 : 0.0310 s
    Time Test mode, step 831 : 0.0470 s
    Time Test mode, step 832 : 0.0310 s
    Time Test mode, step 833 : 0.0320 s
    Time Test mode, step 834 : 0.0310 s
    Time Test mode, step 835 : 0.0470 s
    Time Test mode, step 836 : 0.0310 s
    Time Test mode, step 837 : 0.0310 s
    Time Test mode, step 838 : 0.0470 s
    Time Test mode, step 839 : 0.0310 s
    Time Test mode, step 840 : 0.0320 s
    Time Test mode, step 841 : 0.0470 s
    Time Test mode, step 842 : 0.0310 s
    Time Test mode, step 843 : 0.0310 s
    Time Test mode, step 844 : 0.0310 s
    Time Test mode, step 845 : 0.0470 s
    Time Test mode, step 846 : 0.0310 s
    Time Test mode, step 847 : 0.0320 s
    Time Test mode, step 848 : 0.0470 s
    Time Test mode, step 849 : 0.0310 s
    Time Test mode, step 850 : 0.0310 s
    Time Test mode, step 851 : 0.0310 s
    Time Test mode, step 852 : 0.0470 s
    Time Test mode, step 853 : 0.0310 s
    Time Test mode, step 854 : 0.0320 s
    Time Test mode, step 855 : 0.0470 s
    Time Test mode, step 856 : 0.0310 s
    Time Test mode, step 857 : 0.0310 s
    Time Test mode, step 858 : 0.0310 s
    Time Test mode, step 859 : 0.0470 s
    Time Test mode, step 860 : 0.0310 s
    Time Test mode, step 861 : 0.0320 s
    Time Test mode, step 862 : 0.0470 s
    Time Test mode, step 863 : 0.0310 s
    Time Test mode, step 864 : 0.0310 s
    Time Test mode, step 865 : 0.0310 s
    Time Test mode, step 866 : 0.0470 s
    Time Test mode, step 867 : 0.0310 s
    Time Test mode, step 868 : 0.0320 s
    Time Test mode, step 869 : 0.0470 s
    Time Test mode, step 870 : 0.0310 s
    Time Test mode, step 871 : 0.0310 s
    Time Test mode, step 872 : 0.0310 s
    Time Test mode, step 873 : 0.0470 s
    Time Test mode, step 874 : 0.0310 s
    Time Test mode, step 875 : 0.0320 s
    Time Test mode, step 876 : 0.0470 s
    Time Test mode, step 877 : 0.0310 s
    Time Test mode, step 878 : 0.0310 s
    Time Test mode, step 879 : 0.0310 s
    Time Test mode, step 880 : 0.0470 s
    Time Test mode, step 881 : 0.0310 s
    Time Test mode, step 882 : 0.0320 s
    Time Test mode, step 883 : 0.0470 s
    Time Test mode, step 884 : 0.0310 s
    Time Test mode, step 885 : 0.0310 s
    Time Test mode, step 886 : 0.0310 s
    Time Test mode, step 887 : 0.0470 s
    Time Test mode, step 888 : 0.0310 s
    Time Test mode, step 889 : 0.0470 s
    Time Test mode, step 890 : 0.0320 s
    Time Test mode, step 891 : 0.0310 s
    Time Test mode, step 892 : 0.0470 s
    Time Test mode, step 893 : 0.0310 s
    Time Test mode, step 894 : 0.0310 s
    Time Test mode, step 895 : 0.0470 s
    Time Test mode, step 896 : 0.0310 s
    Time Test mode, step 897 : 0.0320 s
    Time Test mode, step 898 : 0.0310 s
    Time Test mode, step 899 : 0.0470 s
    Time Test mode, step 900 : 0.0310 s
    Time Test mode, step 901 : 0.0310 s
    Time Test mode, step 902 : 0.0470 s
    Time Test mode, step 903 : 0.0310 s
    Time Test mode, step 904 : 0.0320 s
    Time Test mode, step 905 : 0.0310 s
    Time Test mode, step 906 : 0.0470 s
    Time Test mode, step 907 : 0.0310 s
    Time Test mode, step 908 : 0.0310 s
    Time Test mode, step 909 : 0.0470 s
    Time Test mode, step 910 : 0.0310 s
    Time Test mode, step 911 : 0.0320 s
    Time Test mode, step 912 : 0.0310 s
    Time Test mode, step 913 : 0.0470 s
    Time Test mode, step 914 : 0.0310 s
    Time Test mode, step 915 : 0.0310 s
    Time Test mode, step 916 : 0.0470 s
    Time Test mode, step 917 : 0.0310 s
    Time Test mode, step 918 : 0.0320 s
    Time Test mode, step 919 : 0.0310 s
    Time Test mode, step 920 : 0.0470 s
    Time Test mode, step 921 : 0.0310 s
    Time Test mode, step 922 : 0.0310 s
    Time Test mode, step 923 : 0.0470 s
    Time Test mode, step 924 : 0.0310 s
    Time Test mode, step 925 : 0.0320 s
    Time Test mode, step 926 : 0.0310 s
    Time Test mode, step 927 : 0.0470 s
    Time Test mode, step 928 : 0.0310 s
    Time Test mode, step 929 : 0.0310 s
    Time Test mode, step 930 : 0.0470 s
    Time Test mode, step 931 : 0.0310 s
    Time Test mode, step 932 : 0.0320 s
    Time Test mode, step 933 : 0.0310 s
    Time Test mode, step 934 : 0.0470 s
    Time Test mode, step 935 : 0.0310 s
    Time Test mode, step 936 : 0.0310 s
    Time Test mode, step 937 : 0.0470 s
    Time Test mode, step 938 : 0.0310 s
    Time Test mode, step 939 : 0.0320 s
    Time Test mode, step 940 : 0.0310 s
    Time Test mode, step 941 : 0.0470 s
    Time Test mode, step 942 : 0.0310 s
    Time Test mode, step 943 : 0.0310 s
    Time Test mode, step 944 : 0.0470 s
    Time Test mode, step 945 : 0.0310 s
    Time Test mode, step 946 : 0.0320 s
    Time Test mode, step 947 : 0.0460 s
    Time Test mode, step 948 : 0.0320 s
    Time Test mode, step 949 : 0.0310 s
    Time Test mode, step 950 : 0.0310 s
    Time Test mode, step 951 : 0.0470 s
    Time Test mode, step 952 : 0.0310 s
    Time Test mode, step 953 : 0.0320 s
    Time Test mode, step 954 : 0.0460 s
    Time Test mode, step 955 : 0.0320 s
    Time Test mode, step 956 : 0.0310 s
    Time Test mode, step 957 : 0.0310 s
    Time Test mode, step 958 : 0.0470 s
    Time Test mode, step 959 : 0.0310 s
    Time Test mode, step 960 : 0.0320 s
    Time Test mode, step 961 : 0.0310 s
    Time Test mode, step 962 : 0.0470 s
    Time Test mode, step 963 : 0.0310 s
    Time Test mode, step 964 : 0.0310 s
    Time Test mode, step 965 : 0.0470 s
    Time Test mode, step 966 : 0.0310 s
    Time Test mode, step 967 : 0.0320 s
    Time Test mode, step 968 : 0.0460 s
    Time Test mode, step 969 : 0.0320 s
    Time Test mode, step 970 : 0.0310 s
    Time Test mode, step 971 : 0.0310 s
    Time Test mode, step 972 : 0.0470 s
    Time Test mode, step 973 : 0.0310 s
    Time Test mode, step 974 : 0.0320 s
    Time Test mode, step 975 : 0.0460 s
    Time Test mode, step 976 : 0.0320 s
    Time Test mode, step 977 : 0.0310 s
    Time Test mode, step 978 : 0.0310 s
    Time Test mode, step 979 : 0.0470 s
    Time Test mode, step 980 : 0.0310 s
    Time Test mode, step 981 : 0.0320 s
    Time Test mode, step 982 : 0.0460 s
    Time Test mode, step 983 : 0.0320 s
    Time Test mode, step 984 : 0.0310 s
    Time Test mode, step 985 : 0.0310 s
    Time Test mode, step 986 : 0.0470 s
    Time Test mode, step 987 : 0.0310 s
    Time Test mode, step 988 : 0.0320 s
    Time Test mode, step 989 : 0.0460 s
    Time Test mode, step 990 : 0.0320 s
    Time Test mode, step 991 : 0.0310 s
    Time Test mode, step 992 : 0.0310 s
    Time Test mode, step 993 : 0.0470 s
    Time Test mode, step 994 : 0.0310 s
    Time Test mode, step 995 : 0.0320 s
    Time Test mode, step 996 : 0.0460 s
    Time Test mode, step 997 : 0.0320 s
    Time Test mode, step 998 : 0.0310 s
    Time Test mode, step 999 : 0.0310 s
    Time Test mode, step 1000 : 0.0470 s

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Interesting....

    But it doesn't look like it was created by these calls.
    fprintf(profile_file, "create structure:\t\t\t\t\t%8.4f\n", duration);
    fprintf(profile_file, "ProcessMatrixData:\t\t\t\t\t\t\t\t%8.4f\n", duration);
    fprintf(profile_file, "merge matrices:\t\t\t\t\t\t\t\t\t%8.4f\n", duration);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,
    You are right!!!!! But that is the total time taken. I am not much sure about how that C profiling code is working. The
    output that I sent is generated using Fortran code. I am pasting FORTRAN code below, please have a look. This code is
    generating the 1000 steps of test time
    Main.f90
    ---------
    call FormatMatrixComp(FuelDistrib,2,ndMassDscFL,ndMassF L,comp_flags,ZFW_ID,CS_ID)

    #ifdef DO_PROFILE
    T_cpu_tot = SECNDS(T_cpu_start);T_cpu_mg1g1=T_cpu_tot-T_cpu; T_cpu=T_cpu_tot
    tempstr = ''
    write(tempstr,'(A,I4)') 'Time test mode, step', iloop
    call write_profile_data(tempstr,0,T_cpu_mg1g1,ReturnCod e)
    ! call write_profile_info('',ReturnCode) ! print empty line
    #endif
    Note: Fortran Code is for performance analysis and profiling of C project.

    I am unable to debug this function(FormatMatrixComp) since this function is not called anywhere in the C project. I have
    seen this function is called only via Fortran files.

    Can you please able to advice me how should I move ahead?
    Since there are so many unknown memory allocation errors (call from Fortran to C proj). I am stuck with code, debugging
    is occurring only up to certain extent.
    If my question is unclear/ confusing please let me know. Please reply me quickly

    Note the sample values of FuelDistrib:
    --------------------------------


    FuelDistrib(1,1,1) 0.000000000000000D+000 REAL(8)
    FuelDistrib(2,1,1) 0.000000000000000D+000 REAL(8)
    FuelDistrib(3,1,1) 0.000000000000000D+000 REAL(8)

    .................................................. ......
    .................................................. ......
    .................................................. ......
    .................................................. ......
    FuelDistrib(6,10,2) -170.091339111328 REAL(8)
    FuelDistrib(7,10,2) 398.197937011719 REAL(8)
    FuelDistrib(8,10,2) 357.680664062500 REAL(8)
    FuelDistrib(9,10,2) 245.521957397461 REAL(8)
    FuelDistrib(10,10,2) 18.7959365844727 REAL(8)

    .................................................. ......
    .................................................. ......
    .................................................. ......


    FuelDistrib(33,10,2) 0.000000000000000D+000 REAL(8)
    FuelDistrib(34,10,2) 0.000000000000000D+000 REAL(8)
    FuelDistrib(35,10,2) 0.000000000000000D+000 REAL(8)

  8. #8
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,

    Waiting for your reply. kindly respond when you logged in.

  9. #9
    Ultraviolence Connoisseur
    Join Date
    Mar 2004
    Posts
    472
    Since Salem is not here at the moment, I'll give you some ideas.
    Code:
      // initialize ams structure to zero
      for (nComp = 0; nComp < tempAMSdata.nComp_d; ++nComp) {
        for (i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip; ++i) {
          for (j = 0; j < 10; ++j)
            tempAMSdata.stpDcomp[nComp].fpProps[i][j] = 0;
        }
        for (i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip; ++i) {
          for (j = 0; j < 3; ++j)
            tempAMSdata.stpDcomp[nComp].fpCoords[i][j] = 0;
        }
      }
    Can you show us the definition of tempAMSdata? Most likely this little mess of loops can be reduced to a few statements with proper initialization techniques. Probably won't gain a WHOLE lot of speed on it but it will definitely make the code cleaner.

    Which moves me on to the next section of for loops:
    Code:
      // loop over all matrices
      for (p = 0; p < *nmat; p++) {
        lpdata.nBalasts = *nrow;
     
        if (*nrow != nrow_old) {
          // free memory allocated for structure in second and third dimension before reallocating first dimension
          for (i = 0; i < nrow_old; ++i) {
            for (j = 0; j < 1; ++j)
              free(lpdata.stBalast[i].lpBalastMatrix[j]);
            free(lpdata.stBalast[i].lpBalastMatrix);
          }
     
          // reallocate structure with new dimensions
          lpdata.stBalast =
              (struct balast_section *) realloc(lpdata.stBalast, sizeof(struct balast_section) * *nrow);
          for (i = 0; i < *nrow; ++i) {
            lpdata.stBalast[i].lpBalastMatrix = (double **) malloc(sizeof(double *) * 1);
            for (j = 0; j < 1; ++j) {
              lpdata.stBalast[i].lpBalastMatrix[j] = (double *) malloc(sizeof(double) * 10);
              for (k = 0; k < 10; ++k) {
                lpdata.stBalast[i].lpBalastMatrix[j][k] = 0;  // initialize values to zero
              }
            }
          }
          // remember old dimensions
          nrow_old = *nrow;
        }
         
        // storage of FORTRAN matrix
       for (k = 0; k < *ncol; k++) {
          for (i = 0; i < *nrow; i++) {
            lpdata.stBalast[i].nRows = 1;
            lpdata.stBalast[i].nColumns = *ncol;
            lpdata.stBalast[i].lpBalastMatrix[0][k] = *(matrix++);
          }
        }
     
        if (!createLPams(cpFileName, &stGeoxData, &stG2SData, &lpdata, &tempAMSdata, comp_flag)) {
          // printf( "\n\ file creation Failed..............\n" ) ;
          // fputs( "\file creation Failed..............", fStream ) ;
        } else {
          // printf( "\ file creation successful..............\n" ) ;
          // fputs( "\ file creation successful..............", fStream ) ;
          LPAMSCreated = 1;
        }
     
        if (LPAMSCreated == 1) {
          // printf( "\ File creation is complete..............\n" ) ;
          // fputs( "\ File creation is complete..........", fStream ) ;
        }
        (comp_flag++);
      }                             // loop over all matrices
    This looks like O(n**4) or perhaps even worse performance and definitely this is the main piece of your code (at least the code you posted) that you should be trying to optimize (by removing loops if possible and probably changing out the algorithm entirely). Really the main suggestion I have here is that you probably need to re-think your algorithm and perhaps do some research for any existing algorithms that achieve what you want. Especially with matrix I'm quite sure there are all kinds of mathematical tricks you can use to create a better algorithm then what you have currently (better algorithm > code optimization).

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,422
    Post #7 was useless information - this is a C forum not a Fortran forum.

    Your 1000 line post #5 adds up to 35 seconds, not "Below Function is taking 3-5 sec of time to complete" (post #1).
    Oh wait, that was a typo in post #1, I took 3-5 as being "from 3 to 5 seconds". It really was 35 seconds all along.

    > I am not much sure about how that C profiling code is working.
    Yet somehow you managed to edit the code to put it in there.
    Ah, but on closer inspection, it seems it never worked anyway, or you never tried it.

    Try this approach
    Code:
    #include <stdio.h>
    #include <time.h>
    
    #ifdef PROFILE
    #define MAX_TIMES 1000
    static struct {
      clock_t       start;
      clock_t       created;
      clock_t       processed;
      clock_t       merged;
    } times[1000];
    static int nSample = 0;
    #endif
    
    void FormatMatrixComp(double *matrix, int *nmat, int *nrow, int *ncol, int *comp_flag,
                          int *idbaseMat, int *idtargetMat)
    {
      int i, j, k, p;
      struct MG1G1_ *ptTargetMat;   // will be used to point to target matrix depending on value of idtargetMat
      // initialization of structures
      // char * cpReadString = ( char * ) malloc ( 1024 ) ;
      // char * cpFileName = ( char * ) malloc ( 1024 ) ;
    
      char *cpFileName = NULL;      // not needed in this version
      FILE *fStream = NULL;         // dummy file pointer
      int nRow = 0;
      int nColumn = 0;
      int nComp = 0;
      short tempMG1G1Created = 0;
      static nrow_old = 0;
      static firsttime = 1;
    
    #ifdef PROFILE
      times[nSample].start = clock();
    #endif
    
      // memory allocation of structure (only if dimension changed since last call)
      // all other temporary structures used within this function call
    
      // initialize ams structure to zero
      for (nComp = 0; nComp < tempAMSdata.nComp_d; ++nComp) {
        for (i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip; ++i) {
          for (j = 0; j < 10; ++j)
            tempAMSdata.stpDcomp[nComp].fpProps[i][j] = 0;
        }
        for (i = 0; i < tempAMSdata.stpDcomp[nComp].nStrip; ++i) {
          for (j = 0; j < 3; ++j)
            tempAMSdata.stpDcomp[nComp].fpCoords[i][j] = 0;
        }
      }
    
      // loop over all matrices
      for (p = 0; p < *nmat; p++) {
        lpdata.nBalasts = *nrow;
    
        if (*nrow != nrow_old) {
          // free memory allocated for structure in second and third dimension before reallocating first dimension
          for (i = 0; i < nrow_old; ++i) {
            for (j = 0; j < 1; ++j)
              free(lpdata.stBalast[i].lpBalastMatrix[j]);
            free(lpdata.stBalast[i].lpBalastMatrix);
          }
    
          // reallocate structure with new dimensions
          lpdata.stBalast =
              (struct balast_section *) realloc(lpdata.stBalast, sizeof(struct balast_section) * *nrow);
          for (i = 0; i < *nrow; ++i) {
            lpdata.stBalast[i].lpBalastMatrix = (double **) malloc(sizeof(double *) * 1);
            for (j = 0; j < 1; ++j) {
              lpdata.stBalast[i].lpBalastMatrix[j] = (double *) malloc(sizeof(double) * 10);
              for (k = 0; k < 10; ++k) {
                lpdata.stBalast[i].lpBalastMatrix[j][k] = 0;  // initialize values to zero
              }
            }
          }
          // remember old dimensions
          nrow_old = *nrow;
        }
    
        // storage of FORTRAN matrix
        for (k = 0; k < *ncol; k++) {
          for (i = 0; i < *nrow; i++) {
            lpdata.stBalast[i].nRows = 1;
            lpdata.stBalast[i].nColumns = *ncol;
            lpdata.stBalast[i].lpBalastMatrix[0][k] = *(matrix++);
          }
        }
    
        if (!createLPams(cpFileName, &stGeoxData, &stG2SData, &lpdata, &tempAMSdata, comp_flag)) {
          // printf( "\n\ file creation Failed..............\n" ) ;
          // fputs( "\file creation Failed..............", fStream ) ;
        } else {
          // printf( "\ file creation successful..............\n" ) ;
          // fputs( "\ file creation successful..............", fStream ) ;
          LPAMSCreated = 1;
        }
    
        if (LPAMSCreated == 1) {
          // printf( "\ File creation is complete..............\n" ) ;
          // fputs( "\ File creation is complete..........", fStream ) ;
        }
        (comp_flag++);
      }                             // loop over all matrices
    
    #ifdef PROFILE
      times[nSample].created = clock();
    #endif
    
      // Write file for validation purposes
      /*********************************************************************/
      /* CREATE MATRIX FROM STRUCTURE ... */
      /*********************************************************************/
      /********************************Processing Files Operation *****************************/
      stReturn = GetOnesMetrixDouble(tempMG1G1.dbpMG1G1_data, tempMG1G1.nRow, tempMG1G1.nColumn, 0);  // initialize tempMG1G1 to zero
    
      if (0 == ProcessMatrixData(&stProjectSpace, &tempAMSdata,
                                 &stGeoxData, &stMatrixdata, &stG2SData, &tempMG1G1, fStream)) {
      } else {
        tempMG1G1Created = 1;
        stReturn =
            GetOnesMetrixDouble(stouttempMG1G1->dbpMG1G1_data, stouttempMG1G1->nRow,
                                stouttempMG1G1->nColumn, 0);
        if (0 == ConvertToG1SixMatrix(&tempMG1G1, stouttempMG1G1)) {
          stReturn = 0;
        } else {
          stReturn = 1;
        }
      }
    
    #ifdef PROFILE
      times[nSample].processed = clock();
    #endif
    
      /***************************************************************************************/
      /* MERGE CREATED MATRIX WITH BASE MATRIX TO CREATE TARGET MATRIX ... */
      /***************************************************************************************/
    
      // select target matrix according to value of switch idbaseMat
      switch (*idtargetMat) {
      case OWE_ID:
        ptTargetMat = &stoutMg1g1OWE;
        break;
      case ZFW_ID:
        ptTargetMat = &stMg1g1ZFW;
        break;
      case CS_ID:
        ptTargetMat = &stMg1g1CS;
        break;
      }
      stReturn = GetOnesMetrixDouble(ptBaseMat->dbpMG1G1_data, ptBaseMat->nRow, ptBaseMat->nColumn, 0);
    
      // initialize structure to zero
      // copy values of original baseMat to temporary baseMat container row by row to prevent mixing up of data in the merging process
      // (which matrix to select as baseMat depends on value of input flag idbaseMat)
      for (nRow = 0; nRow < ptBaseMat->nRow; ++nRow) {
        switch (*idbaseMat) {
        case OWE_ID:
          memcpy(ptBaseMat->dbpMG1G1_data[nRow], stoutMg1g1OWE.dbpMG1G1_data[nRow],
                 sizeof(double) * ptBaseMat->nColumn);
          break;
        case ZFW_ID:
          memcpy(ptBaseMat->dbpMG1G1_data[nRow], stMg1g1ZFW.dbpMG1G1_data[nRow],
                 sizeof(double) * ptBaseMat->nColumn);
          break;
        case CS_ID:
          memcpy(ptBaseMat->dbpMG1G1_data[nRow], stMg1g1CS.dbpMG1G1_data[nRow],
                 sizeof(double) * ptBaseMat->nColumn);
          break;
        }
      }
    
      // initialize values of target matrix and cg matrix to zero
      stReturn =
          GetOnesMetrixDouble(ptTargetMat->dbpMG1G1_data, ptTargetMat->nRow, ptTargetMat->nColumn, 0);
      stReturn = GetOnesMetrixDouble(CGMatrix, ptTargetMat->nRow, 3, 0);
    
      // merge created matrix with base matrix to create target matrix
      if (0 == MergeMatrices(ptBaseMat, stouttempMG1G1, &stGeoxData, ptTargetMat, CGMatrix)) {
        stReturn = 0;
      } else {
        stReturn = 1;
      }
    
    #ifdef PROFILE
      times[nSample].merged = clock();
    #endif
    
    #ifdef PROFILE
      {
        // The array is full, dump the contents to a file
        if ( ++nSample == MAX_TIMES ) {
          FILE *fp = fopen("profiledata.txt","a");
          if ( fp ) {
            int i;
            for ( i = 0 ; i < nSample ; i++ ) {
              fprintf(fp,"%ld,%ld,%ld,%ld\n", 
                      times[i].start, times[i].created, 
                      times[i].processed, times[i].merged );
            }
            nSample = 0;    // allow more data
            fclose(fp);
          } else {
            // use perror() to find out why
            fprintf(stderr,"Unable to open profiledata.txt\n");
          }
        }
      }
    #endif
    }                               // end of function
    To compile the code normally, you do this.
    gcc prog.c

    To compile it with profiling enabled, you do this
    gcc -DPROFILE prog.c

    How it works:
    At key points within the function, the current clock is read and stored in persistent (doesn't change between calls) memory.

    Every 1000'th call (change #define MAX_TIMES to your needs), the whole data is written to the file and the counter reset to allow more data to be added.
    This is just the raw data, analysis is done after the program has finished. It is written as a .CSV to allow it to be easily imported into your favourite spreadsheet program.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  11. #11
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear nonpuz,
    Thank you very much for the useful answer. As you asked I am providing the structure of "asm_data tempAMSdata" (note the last struct). Please
    find the code below and please advice me and let me know if there is anything else should I provide. Waiting for your reply.

    Code:
    //variables used in FormatMatrixComp routine
    extern struct MG1G1_ tempMG1G1 = {0,0,NULL};
    extern struct MG1G1_ * stouttempMG1G1 = NULL;
    extern struct MG1G1_ * ptBaseMat = NULL;
    extern struct LP_data lpdata = {0,1,10,NULL,NULL};
    struct asm_data tempAMSdata = {0,0,0,0,NULL,NULL,NULL};

  12. #12
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear Salem,

    Thank you very much for the answer and suppot, very useful. I will work according to this and I may come back to u for same issue further.

  13. #13
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,323
    Code:
    for (j = 0; j < 1; ++j)
      free(lpdata.stBalast[i].lpBalastMatrix[j]);
    Why not do this?...
    Code:
    free(lpdata.stBalast[i].lpBalastMatrix[0]);
    Fact - Beethoven wrote his first symphony in C

  14. #14
    TEIAM - problem solved
    Join Date
    Apr 2012
    Location
    Melbourne Australia
    Posts
    1,323
    Code:
    if (0 == ProcessMatrixData(&stProjectSpace, &tempAMSdata,
                                 &stGeoxData, &stMatrixdata, &stG2SData, &tempMG1G1, fStream)) {
      } else {
    ...
    Code:
    if (0 != ProcessMatrixData(&stProjectSpace, &tempAMSdata,
                                 &stGeoxData, &stMatrixdata, &stG2SData, &tempMG1G1, fStream)) {
    ...
    Fact - Beethoven wrote his first symphony in C

  15. #15
    Registered User
    Join Date
    Jan 2013
    Posts
    13
    Dear friend,

    Thanks a lot for the answer, I will try and let u know

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Optimize?
    By nuko in forum C Programming
    Replies: 3
    Last Post: 12-21-2011, 12:14 AM
  2. Please help me optimize my code
    By lazyme in forum C++ Programming
    Replies: 3
    Last Post: 01-25-2010, 03:05 AM
  3. Help me optimize this function
    By h3ro in forum C++ Programming
    Replies: 15
    Last Post: 02-24-2008, 05:40 PM
  4. Help me optimize
    By sand_man in forum Game Programming
    Replies: 14
    Last Post: 05-10-2005, 05:19 PM
  5. How to Optimize
    By cfrost in forum C++ Programming
    Replies: 5
    Last Post: 11-09-2004, 08:07 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21