home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sgi / 13586 < prev    next >
Encoding:
Text File  |  1992-09-13  |  3.7 KB  |  93 lines

  1. Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!merlin!resmel.bhp.com.au!morgana!tim
  2. Newsgroups: comp.sys.sgi
  3. Subject: A titbit about the FM & Irix 4.0.5 (and a question)
  4. Message-ID: <1992Sep14.164513.138@vulcan.resmel.bhp.com.au>
  5. From: tim@resmel.bhp.com.au (Tim Monks)
  6. Date: 14 Sep 92 16:45:12 +1000
  7. Nntp-Posting-Host: morgana.resmel.bhp.com.au
  8. X-Newsreader: Tin 1.1 PL5
  9. Lines: 82
  10.  
  11. Whilst trying to improve the efficiency of some horrible code I had
  12. written, I discovered the following titbit about the font manager (which
  13. may be of interest to other developers using the FM library).  Some of
  14. you may recognise the origins of this code snippet from Mark Overmars'
  15. FORMS library.  The timings are for a medium loaded 340VGX running Irix
  16. 4.0.5.
  17.  
  18. -----8<----------------------------------------------------
  19. #include <stdio.h>
  20. #include <malloc.h>
  21. #include <fmclient.h>
  22.  
  23. main(void)
  24. {
  25.     /* 
  26.        Compile with:
  27.        cc -g -o foo foo.c -lmalloc -lfm_s -lgl_s
  28.     */
  29.     static fmfonthandle thefont[5], smallfont[5], normalfont[5], largefont[5];
  30.     int             i;
  31.  
  32.     mallopt(M_DEBUG, 1);    /* this is the statement to watch */
  33.     fminit();
  34.     thefont[0] = fmfindfont("Helvetica");
  35.     thefont[1] = fmfindfont("Helvetica-Bold");
  36.     thefont[2] = fmfindfont("Helvetica-BoldOblique");
  37.     thefont[3] = fmfindfont("Courier");
  38.     for (i = 0; i < 4; i++)
  39.     {
  40.     smallfont[i] = fmscalefont(thefont[i], 8.0);
  41.     normalfont[i] = fmscalefont(thefont[i], 10.0);
  42.     largefont[i] = fmscalefont(thefont[i], 18.0);
  43.     }
  44. }
  45. -----8<----------------------------------------------------
  46.  
  47. Timing with mallopt:   66.840u 0.460s 1:07.31 99.9% 0+0k 2+0io 0pf+0w
  48. Timing without mallopt: 2.320u 0.320s 0:02.63 100.3% 0+0k 0+0io 0pf+0w
  49.                                       =======
  50. ie: from 67 secs down to 2 secs. 
  51.  
  52. We have an old 50G running 4.0.1, and the results on that are:
  53. Timing with mallopt:    0.129u 0.429s 0:05.39 10.0% 0+0k 35+0io 25pf+0w
  54. Timing without mallopt: 0.119u 0.409s 0:06.96 7.3% 0+0k 49+0io 29pf+0w
  55.  
  56. ie: no significant difference in the older Irix 4.0.1.
  57.  
  58. I suppose these results should not be too suprising, after all the font
  59. manager will be thumping a little of memory, but I have never seen any
  60. other code so dramatically affected by mallopt.  
  61.  
  62. Now for a little complaint: 
  63. I read the release notes for 4.0.5 fairly well (imho) and the only
  64. mention I saw on the font manager and memory allocation was 12-3: "The
  65. IRIS FM now allocates memory differently, so the functions fmcachelimit,
  66. ..  are no longer needed." Not much of a hint there of any other
  67. consequences of the change.  In defence of SG, the manual page for
  68. malloc(3X) says that with M_DEBUG on, "...the performance of malloc is
  69. reduced considerably." (but heck, the code the above snippet came from,
  70. has been mutating over a year; I read the manual page for mallopt
  71. several months ago when I was chasing malloc problems, and took no
  72. notice of the warning.)
  73.  
  74.  
  75. Now the question:
  76. I have some code (pure gl, many windows) and I want fancy text in each
  77. of them.  Is it completely safe to do all the fminit, fmfindfont's and
  78. fmscalefont's ONCE ONLY at the start of the program before any windows
  79. get opened, and then use the appropriate handles in all the different
  80. windows, or should I use separate font initialisations for each window ?
  81. (what I want to know is: is there any interaction between the GL
  82. transformation matrices and the page matrices that I should know about ?)
  83.  
  84. I will post the definite answer to this if I receive one.
  85.  
  86.  
  87. --
  88. Dr Tim Monks
  89. Exploration Group                      | (direct)   (+61-3)566-7448
  90. BHP Research - Melbourne Laboratories  | (switch)   (+61-3)560-7066
  91. 245 Wellington Rd, Mulgrave, 3170,     | (fax)      (+61-3)561-6709
  92. AUSTRALIA                              | (internet) tim@resmel.bhp.com.au
  93.