Processing Power


Bicky22

Recommended Posts

Is there any way I can quantify how much processing power I need to run a given program?

 

For example: If I have a program communicating with multiple Labjacks, running multiple sequences at once, some containing execute and evaluate functions, as well as reading, manipulating, and exporting data, how can I determine whether the computers processor can actually handle it all? 

 

Thank you for your help.  

Link to comment
Share on other sites

Profiling is challenging in any development tool.  The only real way to tell if the CPU is keeping up is to actually time your loops and see how long they take.  At its simplest, you do something like:

 

   while(1)

       private st = systime()

       // all your code

       ? systime() - st

       delay(1)

   endwhile

 

This will time how long it takes to run your loop, minus the delay.  The total loop time is the delay (in this case 1) plus the displayed time.  You could also put the delay() in front of the ? to get the total loop time (approximate).  Either way, that will tell you if your loops are running as fast as you want.  If they are, and the CPU usage in task manager is below 100, you are good.

 

Of course just looking at task manager is often a good indicator.  A lot of times, however, the limit isn't the CPU, but rather the communications with the devices.  This is most often the bottleneck and limiting factor, and no amount of CPU power is going to help.  If it is a real bottleneck, you have to redesign how you are communicating, for example, grouping your requests into single queries, or possibly streaming.

Link to comment
Share on other sites

Ok thank you, I appreciate the response. I'm not finished with the script or wiring so I am not ready to test anything, this was something that I just had in the back of my mind. 

 

I have a USB 2.0 hooked into a USB hub that spits to a LJ U9 pro  and U12 right now, is there a better option?

Link to comment
Share on other sites

No, probably not, though I would keep other devices off the hub.  The bottleneck is the device itself more than the hub.  The UE9 is pretty quick, but still takes a few milliseconds for each query.  However, you can batch a bunch of queries together and get much better performance.  The U12 is a much older device (nearly 15 years now!) and does things differently.  It takes nearly 20ms to do a query and there is only so much you can do in each query.  But again, some batching can help, but really if you need better performance than the U12, you should get a U3 instead.

Link to comment
Share on other sites

Those are the only devices on the hub. I think I will be ok with the U12, unless it will slow up DAQ factory as well. I am only using the U12 to control relays on an RB16 board, not take readings. If the relays are 20 ms slow I should be alright. 

 

Are you referring to batch logging? section 5.2 of the DAQFactory - LabJack Application guide. Please correct me if I am wrong, but my understanding is logging only allows you to save the given data. My problem is I need to take the data read (preferably quick as possible), once a certain value is reached have the program react. 

 

For example 

 

While(1)

read(channel)

 

endwhile

Link to comment
Share on other sites

No, I'm talking about batching your reads.  If you do:

 

while(1)

   read(myChannel)

   read(AnotherChannel)

   delay(1)

endwhile

 

Then DAQFactory has to make two separate queries to the device.  Instead you should batch or combine the queries.  There are a number of ways to do it, but the easiest is to put the input channels for the device in the same channel group (no output channels!) and then use:

 

channel.readGroup("myGroup")

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.