home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / pgmutil / val_link.zip / ENDLINK.C < prev    next >
Text File  |  1989-02-18  |  9KB  |  199 lines

  1. /*                                ENDLINK.C                               */
  2.  
  3. /*+-------------------------------------------------------------------------+
  4.   |                                                                         |
  5.   |                           end_linker                                    |
  6.   |                                                                         |
  7.   +-------------------------------------------------------------------------+*/
  8. void end_linker(bit_16 return_code)
  9. BeginDeclarations
  10. EndDeclarations
  11. BeginCode
  12.  If statistics.val IsTrue
  13.   Then
  14.    linker_statistics();
  15.   EndIf;
  16.  exit(return_code);
  17. EndCode
  18.  
  19. /*+-------------------------------------------------------------------------+
  20.   |                                                                         |
  21.   |                           linker_statistics                             |
  22.   |                                                                         |
  23.   +-------------------------------------------------------------------------+*/
  24. void linker_statistics()
  25. BeginDeclarations
  26. file_info_ptr                          file;
  27. #define File                           (*file)
  28. EndDeclarations
  29. BeginCode
  30.  statistics_start_time = Now;
  31.  statistics.val        = False;  /* Prevent recursive call. */
  32. /*+-------------------------------------------------------------------------+
  33.   |                                                                         |
  34.   |                       Memory Usage Statistics                           |
  35.   |                                                                         |
  36.   +-------------------------------------------------------------------------+*/
  37.  If link_step Exceeds 0
  38.   Then
  39.    linker_message("\n"
  40.                   "Memory Usage Statistics:\n"
  41.                   "---Memory Pool---  --Size--  --Used--  --Free--  %%Free\n");
  42.    edit_number_string(temp_string, "%lu", free_pool.pool_size);
  43.    linker_message("%-17s  %8Fs\n",
  44.                   free_pool.pool_id,
  45.                   String(temp_string));
  46.    edit_number_string(temp_string, "%lu", static_pool.pool_size);
  47.    linker_message("%-17s  %8Fs  ",
  48.                   static_pool.pool_id,
  49.                   String(temp_string));
  50.    edit_number_string(temp_string, "%lu", static_pool.used_bytes);
  51.    linker_message("%8Fs  ",
  52.                   String(temp_string));
  53.    edit_number_string(temp_string, "%lu",
  54.                       static_pool.pool_size - static_pool.used_bytes);
  55.    linker_message("%8Fs  %4u%%\n",
  56.                   String(temp_string),
  57.                   Bit_16((100L*(static_pool.pool_size -
  58.                                 static_pool.used_bytes)) /
  59.                          static_pool.pool_size));
  60.   EndIf;
  61.  
  62. /*+-------------------------------------------------------------------------+
  63.   |                                                                         |
  64.   |                        Object File Statistics                           |
  65.   |                                                                         |
  66.   +-------------------------------------------------------------------------+*/
  67.  
  68.  If (link_step Exceeds 4) AndIf (obj_file_list.first IsNotNull)
  69.   Then
  70.    linker_message("\n"
  71.                   "Object File Statistics:\n");
  72.    linker_message("--Size--  -------------Object File-------------\n");
  73.    TraverseList(obj_file_list, file)
  74.     BeginTraverse
  75.      edit_number_string(temp_string, "%lu", File.file_size);
  76.      linker_message("%8Fs  %Fs\n", String(temp_string), File.filename);
  77.     EndTraverse;
  78.   EndIf;
  79.  
  80. /*+-------------------------------------------------------------------------+
  81.   |                                                                         |
  82.   |                        Library File Statistics                          |
  83.   |                                                                         |
  84.   +-------------------------------------------------------------------------+*/
  85.  
  86.  If (link_step Exceeds 4) AndIf (lib_file_list.first IsNotNull)
  87.   Then
  88.    linker_message("\n"
  89.                   "Library File Statistics:\n");
  90.    linker_message("--Size--  Modules  Passes  "
  91.                   "-------------Library File------------\n");
  92.    TraverseList(lib_file_list, file)
  93.     BeginTraverse
  94.      edit_number_string(temp_string, "%lu", File.file_size);
  95.      linker_message("%8Fs  ",
  96.                     String(temp_string));
  97.      edit_number_string(temp_string, "%u",  File.module_count);
  98.      linker_message("%7Fs  ",
  99.                     String(temp_string));
  100.      edit_number_string(temp_string, "%u",  File.pass_count);
  101.      linker_message("%6Fs  %Fs\n",
  102.                     String(temp_string),
  103.                     File.filename);
  104.     EndTraverse;
  105.   EndIf;
  106.  
  107. /*+-------------------------------------------------------------------------+
  108.   |                                                                         |
  109.   |                       Time Usage Statistics                             |
  110.   |                                                                         |
  111.   +-------------------------------------------------------------------------+*/
  112.  total_time = 0;
  113.  linker_message("\n"
  114.                 "Time Usage Statistics:\n");
  115.  If link_step Exceeds 0
  116.   Then
  117.    total_time += user_input_start_time - linker_start_time;
  118.    linker_message("  Primary linker initialization time:%7s\n",
  119.                   elapsed_time(linker_start_time,
  120.                                user_input_start_time));
  121.   EndIf;
  122.  If link_step Exceeds 1
  123.   Then
  124.    total_time += secondary_init_start_time - user_input_start_time;
  125.    linker_message("                     User input time:%7s\n",
  126.                   elapsed_time(user_input_start_time,
  127.                                secondary_init_start_time));
  128.   EndIf;
  129.  If link_step Exceeds 2
  130.   Then
  131.    total_time += library_directory_start_time -
  132.                  secondary_init_start_time;
  133.    linker_message("Secondary linker initialization time:%7s\n",
  134.                   elapsed_time(secondary_init_start_time,
  135.                                library_directory_start_time));
  136.   EndIf;
  137.  If link_step Exceeds 3
  138.   Then
  139.    total_time += object_module_start_time - library_directory_start_time;
  140.    linker_message("   Library directory processing time:%7s\n",
  141.                   elapsed_time(library_directory_start_time,
  142.                                object_module_start_time));
  143.   EndIf;
  144.  If link_step Exceeds 4
  145.   Then
  146.    total_time += library_processing_start_time - object_module_start_time;
  147.    linker_message("       Object module processing time:%7s\n",
  148.                   elapsed_time(object_module_start_time,
  149.                                library_processing_start_time));
  150.   EndIf;
  151.  If link_step Exceeds 5
  152.   Then
  153.    total_time += order_start_time - library_processing_start_time;
  154.    linker_message("             Library processing time:%7s\n",
  155.                   elapsed_time(library_processing_start_time,
  156.                                order_start_time));
  157.   EndIf;
  158.  If link_step Exceeds 6
  159.   Then
  160.    total_time += fixup_start_time - order_start_time;
  161.    linker_message("  Segment ordering and aligning time:%7s\n",
  162.                   elapsed_time(order_start_time,
  163.                                fixup_start_time));
  164.   EndIf;
  165.  If link_step Exceeds 7
  166.   Then
  167.    total_time += exec_image_start_time - fixup_start_time;
  168.    linker_message("                          Fixup time:%7s\n",
  169.                   elapsed_time(fixup_start_time,
  170.                                exec_image_start_time));
  171.   EndIf;
  172.  If link_step Exceeds 8
  173.   Then
  174.    total_time += map_start_time - exec_image_start_time;
  175.    linker_message("         Executable image write time:%7s\n",
  176.                   elapsed_time(exec_image_start_time,
  177.                                map_start_time));
  178.   EndIf;
  179.  If link_step Exceeds 9
  180.   Then
  181.    total_time += statistics_start_time - map_start_time;
  182.    linker_message("                      Map write time:%7s\n",
  183.                   elapsed_time(map_start_time,
  184.                                statistics_start_time));
  185.   EndIf;
  186.  linker_end_time = Now;
  187.  total_time += linker_end_time - statistics_start_time;
  188.  linker_message("           Statistics reporting time:%7s\n",
  189.                 elapsed_time(statistics_start_time,
  190.                              linker_end_time));
  191.  linker_message("                                      ------\n"
  192.                 "                 Total Elaspsed Time:%7s\n",
  193.                 elapsed_time(0L, total_time));
  194.  
  195.  return;
  196. EndCode
  197. #undef File
  198.  
  199.