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

Scott Bloom scott at towel42.com
Tue Feb 1 17:47:30 CET 2022


😊  that definitely does.

Of course.... I wonder if you had removed that, but left in the QObject etc etc, what would it have been.  Likely, not much worse than 15ms.

Why? IMO, Qt wouldn’t be what it is today, if simply allocating 60k QObjects and connecting a signal to them too that long.

But I think the overall architecture of what you have now, is MUCH better and will scale to a more complex "actually do the work" system much better than the other.

Scott

-----Original Message-----
From: Interest <interest-bounces at qt-project.org> On Behalf Of Murphy, Sean
Sent: Tuesday, February 1, 2022 8:31 AM
To: interest at qt-project.org
Subject: Re: [Interest] [External]Re: How to get QtConcurrent to do what I want?

> 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

_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list