This information might be helpful in designing data structures that maximize the efficiency of your application. For example, if you are considering the trade-offs between storing data in an array or as an attribute of an object, knowing that the
conclude action takes about five times as long as the change action might help you make the best decision. However, bear in mind that you should rarely base design decisions solely on the basis of performance, and you should never overlook the importance of clarity and maintainability of your code.
Caution: G2 internal implementation is subject to change without notice, and future improvements might affect the relative efficiency of G2 actions. Information given here is approximate and applies only to the stated version of G2 on the given platform. The results for different platforms and future versions of G2 might vary.
Example of Comparing Operations: Change Versus Conclude
To compare the efficiency of two types of statements accurately, you can create procedures that run the target statement repeatedly to accumulate a significant amount of elapsed time, usually one or more seconds. For example, to compare the performance of the change action to that of the conclude action, you can profile the following procedures, using the same value of N:
change-test(N: integer)
I: integer;
FA: class float-array;
begin
create a float-array FA;
change the array-length of FA to 10;
for I = 1 to N do
change FA[5] = 1.0;
end;
end
conclude-test(N: integer)
I: integer;
Obj: class test-object;
begin
create a test-object Obj;
for I = 1 to N do
conclude that the float-attribute of Obj = 1.0;
end;
end
empty-test (N:integer)
I = integer;
begin
for i = 1 to N do
end
end
N = 50,000, the results are:
change-test takes 0.37seconds.
conclude-test takes 1.96 seconds.
empty-test takes 0.13 seconds.
change action over the conclude action whenever possible.The time for creating the test object and setting up the array is negligible and can be ignored.
change-test affect the results?
test-object class matter?
conclude-test but instead you referred to it by name?