home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!hubcap!ncrcae!ncrlnk!usglnk!usdsd1!dkowalsk
- From: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
- Newsgroups: comp.unix.questions
- Subject: malloc(3) library
- Message-ID: <1599@usdsd1.DaytonOH.NCR.COM>
- Date: 11 Sep 92 19:36:23 GMT
- Reply-To: dkowalsk@usdsd1.DaytonOH.NCR.COM (Dennis Kowalski)
- Distribution: world
- Organization: NCR USG Data Services Division
- Lines: 84
-
-
- In <dbt.714876030@otto> Dave T. Bath states that the malloc(3) library
- is faster than the default malloc routines.
-
- I wrote the following test program
-
-
- #include <malloc.h>
-
- main()
- {
- int x,y;
- char *p_str1, *p_str2, *p_str5, *p_strx, *p_stry, *p_strz;
-
- long ticks1, ticks2;
-
-
- GETCPUTICKS(ticks1); /* a library routine we have */
-
- for (x=0; x<25000; x++)
- {
- p_str1 = (char *) malloc(10000);
- p_str2 = (char *) malloc(2000);
- p_str5 = (char *) malloc(15000);
- p_strx = (char *) malloc(90000);
- p_stry = (char *) malloc(6000);
- p_strz = (char *) malloc(150000);
- free(p_strx);
- free(p_str2);
- free(p_str1);
- free(p_str5);
- free(p_stry);
- free(p_strz);
- } /* for x */
-
- GETCPUTICKS(ticks2); /* a library routine we have */
-
- printf("\nTest 1 ticks = %d\n",(ticks2 - ticks1));
-
- }
-
-
- and tried it with each malloc routine.
-
- The results were very surprising to say the least.
-
-
- This is the cpu time in ticks (60 ticks per second) using the
- default malloc routines.
-
- Test 1 ticks = 146
-
- This is the timex output for it.
-
- real 7.01
- user 2.81
- sys 0.18
-
- This is the cpu time in ticks (60 ticks per second) using the
- -lmalloc option in the make.
-
- Test 1 ticks = 432
-
- This is the timex output for it.
-
- real 20.16
- user 7.51
- sys 0.40
-
-
-
- As you can see, the malloc(3) routines which are supposed to be faster,
- are over 3 times slower!!!!!!
-
- The tests were done on NCR TOWER 700 with SVR 5.3 and an NCR 3445 with 5.4.
- Both had similar results.
-
- Any ideas as to what is happening ???
-
- --
- Dennis Kowalski NCR Corporation PCD-3 (513) 445-1843
- Systems Architecture 1700 S. Patterson Blvd VOICEplus 622-1843
- USG Data Services Div Dayton, Ohio 45479
- Dennis.Kowalski@DaytonOH.NCR.COM
-