[Interest] [External]Re: How to get QtConcurrent to do what I want?

Murphy, Sean Sean.Murphy at centauricorp.com
Tue Feb 1 17:30:52 CET 2022


> Subject: RE: [Interest] [External]Re: How to get QtConcurrent to do what I
> want?
> 
> Something seems off.
> 
> But without looking at the actual code that is allocation 60k tiles and the
> constructor itself, it just seems like a very expensive construction if the
> "new" + "moving a pointer" is taking 3ms each.

I finally figured that part out. 

Since this is just test code and doesn't do any real work yet, I was putting a delays in 
tile::load() and tile::remap() just to simulate that those functions take time to execute. 
To create a little realism, I was randomizing the amount of that delay instead of using a 
fixed delay. To accomplish that, I mistakenly added a QRandomGenerator as a member 
variable of the tile class, instead of just calling QRandomGenerator::global()->bounded(min, max)
in the tile::load() and tile::remap()functions. Each tile certainly doesn't need its own 
uniquely seed random number sequence...

I just made that switch - removed the QRandomGenerator member variable 
>From the tile class, and calling QRandomGenerator::global()->bounded(min, max). Now 
creating  + assigning each tile plummeted from 18 seconds to 15 milliseconds.

That seems pretty acceptable to me...

Sean



More information about the Interest mailing list