Author Topic: Profiling Gdi+  (Read 559 times)

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Profiling Gdi+
« on: July 16, 2022, 10:33:59 AM »
My animated GIF display proc uses these 16 GdiPlus calls. Guess which one is the slowest... it's not intuitive. If somebody guesses right, I will reveal the surprising results of my profiling :cool:

Code: [Select]
GdipCreateBitmapFromHBITMAP
GdipCreateBitmapFromStream
GdipCreateBitmapFromHBITMAP
GdipCreateHBITMAPFromBitmap
GdipCreateFromHDC
GdipImageGetFrameDimensionsList
GdipImageGetFrameCount
GdipImageSelectActiveFrame
GdipGetPropertyItemSize
GdipGetPropertyItem
GdipGetImageWidth
GdipGetImageHeight
GdipImageRotateFlip
GdipDrawImageRectI
GdipDisposeImage
GdipDeleteGraphics

Hint: most of them cost almost no time, and two account for over 90% of the time. The slowest one is almost three times as slow as the second slowest one :cool:

Code: [Select]
# ------- units slot code ----------
2212          2    9 loading
2158        733   13 worst offender
2212        168   16 second worst offender
2212         10   19 Dispose+Delete

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Profiling Gdi+
« Reply #1 on: July 16, 2022, 11:55:19 AM »
OK, I'll play: intuitively, I'd say GdipCreateBitmapFromStream() and GdipImageRotateFlip() should be the slowest. But they're not, right? (The former because it has to read and decode a bitmap from some data source, the latter because it has to do some transformations on the image.)

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Profiling Gdi+
« Reply #2 on: July 16, 2022, 06:47:18 PM »
OK, I'll play: intuitively, I'd say GdipCreateBitmapFromStream() and GdipImageRotateFlip() should be the slowest. But they're not, right? (The former because it has to read and decode a bitmap from some data source, the latter because it has to do some transformations on the image.)

That's probably what I would have chosen intuitively, too. Nope, they both account for under 1% of the job :cool:

OK, I'll reveal the second slowest:

GdipDrawImageRectI (that's the one that puts the pixels on the screen, so right, that is a lot of work...)