キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

Need Speedup

解決済み
解決策を見る

This runs a bit slow.  Any suggestions on improving performance.  Typically it will iterate between several hundred and a few thousand times.

paul_a_cardinale_1-1712343573285.png

0 件の賞賛
メッセージ1/21
3,619件の閲覧回数
解決策
受理者 paul_a_cardinale

This is nearly 10x faster..

 

Original -     0.14s

Metod #2 -  0.01s

 

I would have been satisfied with 0.1s for 10,000 iterations to begin with. 😉

 

20240405_cds.png

メッセージ2/21
3,599件の閲覧回数

Thanks.

Although 0.1s isn't much, that loop goes inside another loop that iterates several hundred times.

メッセージ3/21
3,590件の閲覧回数

I have always found that building a string as you do is slow. Of course that benchmark is meaningless because both version run in parallel, potentially stepping on each other's toes. Also, the SR should probably be initialized.

 

Currently posting by phone, will have a look later.

0 件の賞賛
メッセージ4/21
3,579件の閲覧回数

@altenbach wrote:

 Also, the SR should probably be initialized.


The SR is the slow part. Remove the SR and concatenate the string like the example above, either by specifying concatenate on the edge of the for loop, or build an array and concatenate after the array, no major difference. Not as fast as the one above, but a significant speed up.

 

 

0 件の賞賛
メッセージ5/21
3,567件の閲覧回数

Note that you can even parallelize the FOR loop. This one is significantly faster on my laptop (3ms vs 480ms).

 

altenbach_0-1712365120025.png

 

There are also a few other alternatives in the other cases, so play around. I am sure there is some slack left.....

 

I took the liberty to change the Y into a simple ramp, but it really should not make a difference.

 

メッセージ6/21
3,519件の閲覧回数

Can the number be statically sized wrt the number of digits? If so the string could be allocated all in one go and then replace the segments with the correct numbers.

~ Helping pave the path to long-term living and thriving in space. ~
0 件の賞賛
メッセージ7/21
1,980件の閲覧回数

Or even allocate a string all at once for the maximum possible number of digits for all entries and replace into that and trim down at the end. Eliminates all the individual string allocations that need to happen with the loop, whether its the reallocation being done for the SR every time or the individual strings that then get concatenated.

~ Helping pave the path to long-term living and thriving in space. ~
0 件の賞賛
メッセージ8/21
1,978件の閲覧回数

I've seen that many times, Strings in shift registers changing sizes are slow, i assume the memory manager doesn't like it. It's fast to make an array of strings and merge them in the end, as the examples do. Making a preallocated string and replacing content might be a good (and old school) alternative.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 件の賞賛
メッセージ9/21
1,913件の閲覧回数

The format into string might also be slow.

 

Format Into String probably parses the format string each iteration. While the string can't change in this example, I don't think the function will change into another function if the format string is a constant.

 

There's a chance though that concatenating a string from constants and more primitive functions is slower that parsing the format string. 

 

This could be benchmarked, but for me refactoring Format Into String usually made things faster...

メッセージ10/21
1,886件の閲覧回数