Applies To: |
|
Summary: |
Question: How fast is cicode? |
Solution: |
Cicode is fast, VERY fast. However this is
a very general question and it does depend on exactly what you want
to do, what operations you want to perform and which functions you
want to call. Simple calculations, assignments, flow control and
calling user functions are very fast in cicode. Citect running on a
486 66Mhz computer can execute around 30,000 lines of this type of
cicode per second. This is the raw execution performance of the
cicode engine. This gives you extremely high performance when
writing cicode programs. However this is not typical of most user
systems as many of the built in cicode functions are slower that
this.
When you call any built in cicode function the cicode engine will very quickly dispatch to a compiled function which was written in the C programming language. This function will run at the maximum performance available to your computer. That is it will run at the same speed if you developed the entire application is the C language itself. The execution time of each built in cicode function will greatly depend on what it is doing. For example if you use the DevOpen() to open a database on a file server then this function may take several hundred milliseconds to execute as it finds the database and opens it. You should note that as the cicode engine quickly dispatches to the compiled C function this is the same time as if your program has been written in the C language. So as a guide any built in cicode function will take the same time to execute if you had called if from the C language. Functions which can take a long time to execute are functions which access files or databases, display data on the screen or wait for some event, remote procedure calls or reading data from the PLC. The best way to test the performance of cicode on your particular application is to put your cicode in the FOR loop of the function below. This function will call you cicode in a loop while taking the time before and after the FOR loop. The function will first calculate the overhead of an empty FOR loop and subtract this to get the execution time of just your code. The execution time and number loops will be displayed on the prompt line after the code has completed executing. We do a Sleep(0) after the first loop so to reduce the chance of being preempted in the second loop, as we will get a fresh time slice. FUNCTION You will need to adjust the number of loops of the FOR statement to get an accurate execution time. If the loops are too small the time may be 0 or 55 ms due to the precision of the clock being 55ms (it may even be -55 ms if the clock tick occurs in the first FOR loop only). You should try to get the execution time around 200 ms for a accurate sample You should also try to not make the loops too big as Citect will then preempt your cicode and you will get a larger number as Citect goes off and does other tasks. You may want to temporary increase the cicode time slice via the parameter [CODE]TimeSlice=1000 to prevent your test from getting preempted. You should not increase the time slice for normal operation as it will degrade the responsiveness of other cicode tasks. As a general rule cicode is very fast, however your cicode will be slowed down by other factors, for example waiting for data from the PLC, from databases or displaying it on the screen. The time you wait for these operations has be optimised to be as fast as possible so that cicode execution is so fast it does not slow down your system. |
Keywords: |
Related Links
Attachments