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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Labtalk extremely slow
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Phillip T.

Germany
19 Posts

Posted - 05/28/2020 :  05:47:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

lkb0221

China
497 Posts

Posted - 05/28/2020 :  10:24:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 05/28/2020 :  12:38:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Phillip T.

Germany
19 Posts

Posted - 05/29/2020 :  02:49:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

Castiel

343 Posts

Posted - 05/31/2020 :  06:31:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
**********************************************************
Go to Top of Page

Chris D

428 Posts

Posted - 06/01/2020 :  09:13:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000