home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / question / 10999 < prev    next >
Encoding:
Text File  |  1992-09-12  |  2.1 KB  |  96 lines

  1. Path: sparky!uunet!gatech!hubcap!ncrcae!ncrlnk!usglnk!usdsd1!dkowalsk
  2. From: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
  3. Newsgroups: comp.unix.questions
  4. Subject: malloc(3) library
  5. Message-ID: <1599@usdsd1.DaytonOH.NCR.COM>
  6. Date: 11 Sep 92 19:36:23 GMT
  7. Reply-To: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
  8. Distribution: world
  9. Organization: NCR USG Data Services Division
  10. Lines: 84
  11.  
  12.  
  13. In <dbt.714876030@otto> Dave T. Bath states that the malloc(3) library
  14. is faster than the default malloc routines.
  15.  
  16. I wrote the following test program
  17.  
  18.  
  19. #include <malloc.h>
  20.  
  21. main()
  22. {
  23. int x,y;
  24. char *p_str1, *p_str2, *p_str5, *p_strx, *p_stry, *p_strz;
  25.  
  26. long ticks1, ticks2;
  27.  
  28.  
  29. GETCPUTICKS(ticks1);    /* a library routine we have */
  30.  
  31. for (x=0; x<25000; x++)
  32. {
  33.   p_str1 = (char *) malloc(10000);
  34.   p_str2 = (char *) malloc(2000);
  35.   p_str5 = (char *) malloc(15000);
  36.   p_strx = (char *) malloc(90000);
  37.   p_stry = (char *) malloc(6000);
  38.   p_strz = (char *) malloc(150000);
  39.   free(p_strx);
  40.   free(p_str2);
  41.   free(p_str1);
  42.   free(p_str5);
  43.   free(p_stry);
  44.   free(p_strz);
  45. }  /* for x */
  46.  
  47. GETCPUTICKS(ticks2);    /* a library routine we have */
  48.  
  49. printf("\nTest 1 ticks = %d\n",(ticks2 - ticks1));
  50.  
  51. }
  52.  
  53.  
  54.  and tried it with each malloc routine.
  55.  
  56.  The results were very surprising to say the least.
  57.  
  58.  
  59. This is the cpu time in ticks (60 ticks per second) using the
  60. default malloc routines.
  61.  
  62. Test 1 ticks = 146
  63.  
  64. This is the timex output for it.
  65.  
  66. real        7.01
  67. user        2.81
  68. sys         0.18
  69.  
  70. This is the cpu time in ticks (60 ticks per second) using the
  71. -lmalloc option in the make.
  72.  
  73. Test 1 ticks = 432
  74.  
  75. This is the timex output for it.
  76.  
  77. real       20.16
  78. user        7.51
  79. sys         0.40
  80.  
  81.  
  82.  
  83. As you can see, the malloc(3) routines which are supposed to be faster,
  84. are over 3 times slower!!!!!!
  85.  
  86. The tests were done on NCR TOWER 700 with SVR 5.3 and an NCR 3445 with 5.4.
  87. Both had similar results.
  88.  
  89. Any ideas as to what is happening ???
  90.  
  91. -- 
  92. Dennis Kowalski         NCR Corporation  PCD-3                  (513) 445-1843
  93. Systems Architecture    1700 S. Patterson Blvd              VOICEplus 622-1843
  94. USG Data Services Div   Dayton, Ohio     45479
  95. Dennis.Kowalski@DaytonOH.NCR.COM
  96.