The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Labtalk extremely slow

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Phillip T. Posted - 05/28/2020 : 05:47:13 AM
Hello Everyone,

i have an issue with my scripts in labtalk running ridiculously slow. For example finding some values in a column and extracting data from an adjacent column takes minutes for about 15000 rows:


e1=$(wks.ncols);
e2=$(MFCrows);

loop(jj,2,$(e1))
{
time = $(interval)*($(jj)-2);
[%H]IRnorm!col($(jj))[L]$= "$(time)";



for(ii=1; ii <= $(e2); ii++)
{
if ($([%H]MFC_T!cell($(ii),5)) <= $(time))
{
fittemp = $([%H]MFC_T!cell($(ii),11));
[%H]Irnorm!col($(jj))[C]$ = $(fittemp);
}
else
{
ii=1000000;
}

}
};


I am a programming newbie and thought this was normal till a college wrote a c++ program that did it in a second.

I have read that labtalk as an interpreted language is slower than compiled ones but this seems excessive.

I have Origin2018b na i5-4590@3.3 GHz and 8 Gb of RAM. What could be the reason for the program running so slow. I wrote quite a bit of code and dont want do relearn/do everything in C++.

Thanks for your help.
5   L A T E S T    R E P L I E S    (Newest First)
Chris D Posted - 06/01/2020 : 09:13:57 AM
Hi Phillip,

Following up on Castiel, perhaps you can ask this question again on our Python forum.

Maybe include more details such as where the interval or MFCrows variables come from (or example values)


Thanks,
Chris Drozdowski
Originlab Technical Support
Castiel Posted - 05/31/2020 : 06:31:48 AM
quote:
Originally posted by Phillip T.

Hi.

Thanks for your answers.
As is said inne d to finding some a value (Time) in one column and extracting data from an adjacent column (Temperature) and then wirte it into the comment of the corresponding column in a different sheet.

Is it really normal that a simple loop ist 1000 times slower than a complete C++ program that reads the files extracts data AND does the operation? If that is really the case i might just switch to C++ after all.



Python is a better option. itertools.takewhile() is the function for your task.


                                          &&&&&&&&&
                                        &&&
                                       &&
                                      &  _____ ___________
                                     II__|[] | |   I I   |
                                    |        |_|_  I I  _|
                                   < OO----OOO   OO---OO
**********************************************************
Phillip T. Posted - 05/29/2020 : 02:49:50 AM
Hi.

Thanks for your answers.
As is said inne d to finding some a value (Time) in one column and extracting data from an adjacent column (Temperature) and then wirte it into the comment of the corresponding column in a different sheet.

Is it really normal that a simple loop ist 1000 times slower than a complete C++ program that reads the files extracts data AND does the operation? If that is really the case i might just switch to C++ after all.
cpyang Posted - 05/28/2020 : 12:38:14 PM
Looping in Latbalk is slow, best way is to use Column Formula. Maybe you can describe what you need to do and we can show you how to write the formula.

CP
lkb0221 Posted - 05/28/2020 : 10:24:17 AM
Maybe replace the [Book]Sheet!Cell(row, col) by using range variables would speed it up a little.

Also, you can use the Index() function to search for the closest value instead of doing the loop.

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000