0

I use delphi xe6 and dual cores.

In my former question many have answered to use multi threads to disperse core load. Thanks.

I coded an over loaded sample. In this sample I didn't use multi threads but the load disperses.

Please let me know the reason the load disperses without multi-thread coding and the cpu usage is limited around 50% during the calculation?

And if I use tParallel.For in xe7 the performance(specifically the cpu usage) will be better?

Thanks always.

enter image description here

Community
  • 1
  • 1
JO SeongGng
  • 567
  • 3
  • 18

1 Answers1

4

If you have two cores and a single-threaded program that is CPU-bound, then you should expect to see the average CPU usage for your system somewhere around 50%, representing 100% divided by 2 CPUs.

I don't read the language of the UI shown in your picture, so I can't read the labels, but it appears to illustrate just what I described. The bottom two graphs, when averaged, yield the top graph. Your program might not be running exclusively on a single CPU; the OS is at liberty to schedule your program to run on either core for each time slice.

Your code doesn't parallelize well; it still updates a single shared resource in the window caption. You should expect roughly equal to worse performance when run in parallel: You'll see twice as much CPU usage, but for about half as much time. It will probably skew worse, though, because of the contention over the window caption from multiple threads.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • 1
    Twice as much CPU usage for half the time is a pretty good deal when parallelizing. I think you mean to say something else with that line. The other problem with `FloatToStr` is that strings are very memory intensive and the memory manager (at least the standard one) is single threaded and serializes memory allocation across all threads in the application. Ten threads making strings can't do it any faster than one thread... – J... Jun 27 '15 at 11:20
  • ...and OP's UI language is Korean - that's the windows resource monitor (CPU Total, Service load, CPU0, CPU1). Indeed it is as you suspect. – J... Jun 27 '15 at 11:22
  • i got to know the reason was serial time slice not parallel. i solved it with multi threads. thanks. – JO SeongGng Jun 28 '15 at 01:29
  • @J... yes it is. regardless of any languages the displays of windows 8 are same. thanks. – JO SeongGng Jun 28 '15 at 01:31