Home > Back-end >  On the issue of the performance, everybody to help.
On the issue of the performance, everybody to help.

Time:10-05

I have a project now, very much, I now want to refactor, everybody help performance analysis,

I now the idea is to put each function modular, that is a feature into a single unit (used to be all basic functions in one unit, and is a global function or variable),


Such as the original function:
Type
Var
B: Integer;
{omit N more variable declarations}

Procedure (a);
{omit N process statement more}
Implementation


Now, I want a new unit

Txx=class
Public
B: Integer;
Procedure (a);
end;
(this class is a function of a class, the total project create a main form in each class to create a performance?)

Txx=record
B: Integer;
Procedure (a);
end;
(this I also can have test structure process, he doesn't need to create you just need to declare, performance?)

There is a new unit
Type
Var
B: Integer;

Procedure (a);
Implementation

At the time of other units calls into the unit name. This method USES a (this should belong to the static, meaning is unit of function, function. Process)

Above three kind of efficiency? The first class, I am afraid that many, many classes are the create so efficiency is no good, but now there is a class method, class method does not need to create, don't know how his performance?

Everybody help decryption puzzle, thanked here

CodePudding user response:

Recommended classes encapsulate code readability, maintainability, which is more important than the performance, of course, if you want to the pursuit of performance, then abandon all the idea of OOP, procedure-oriented programming method is used, plus part of the function USES the assembly implementation, performance improvement will be obvious,

CodePudding user response:

reference 1st floor pathletboy response:
recommended classes encapsulate, code readability, maintainability, which is more important than the performance, of course, if you want to the pursuit of performance, then abandon all the idea of OOP, procedure-oriented programming method is used, plus part of the function USES the assembly implementation, performance improvement will be obvious,


Assembly I don't understand, I also want to get each function module encapsulation, in addition to me the above three kinds of encapsulation way, are there any other way? The above three methods recommended classes? Many classes together create seems really slow

CodePudding user response:

refer to the second floor renaihaore response:
Quote: refer to 1st floor pathletboy response:

Recommended classes encapsulate code readability, maintainability, which is more important than the performance, of course, if you want to the pursuit of performance, then abandon all the idea of OOP, procedure-oriented programming method is used, plus part of the function USES the assembly implementation, performance improvement will be obvious,


Assembly I don't understand, I also want to get each function module encapsulation, in addition to me the above three kinds of encapsulation way, are there any other way? The above three methods recommended classes? Many classes together create seems really slow

What did you have to know the Create what, can't know how slow is slow, don't take it for granted "to Create" is tedious, in addition to some custom initialization, the Create is just applied for memory, for class structure like you structure + method, the structure of the class, is equal to the declared a structure pointer to the pointer to allocate memory space,

CodePudding user response:

reference pathletboy reply: 3/f
Quote: refer to the second floor renaihaore response:

Quote: refer to 1st floor pathletboy response:

Recommended classes encapsulate code readability, maintainability, which is more important than the performance, of course, if you want to the pursuit of performance, then abandon all the idea of OOP, procedure-oriented programming method is used, plus part of the function USES the assembly implementation, performance improvement will be obvious,


Assembly I don't understand, I also want to get each function module encapsulation, in addition to me the above three kinds of encapsulation way, are there any other way? The above three methods recommended classes? Many classes together create seems really slow

What did you have to know the Create what, can't know how slow is slow, don't take it for granted "to Create" is tedious, in addition to some custom initialization, the Create is just applied for memory, for class structure like you structure + method, the structure of the class, is equal to the declared a structure pointer to the pointer to allocate memory space,


Application space this is to know, I like my original code are all global functions, global variables I change each function to each class call big gap? Bad consciousness, I don't know how to test the performance of their classes should be more memory, the least class to save a pointer address in memory

CodePudding user response:

reference 4 floor renaihaore response:
Quote: reference pathletboy reply: 3/f

Quote: refer to the second floor renaihaore response:

Quote: refer to 1st floor pathletboy response:

Recommended classes encapsulate code readability, maintainability, which is more important than the performance, of course, if you want to the pursuit of performance, then abandon all the idea of OOP, procedure-oriented programming method is used, plus part of the function USES the assembly implementation, performance improvement will be obvious,


Assembly I don't understand, I also want to get each function module encapsulation, in addition to me the above three kinds of encapsulation way, are there any other way? The above three methods recommended classes? Many classes together create seems really slow

What did you have to know the Create what, can't know how slow is slow, don't take it for granted "to Create" is tedious, in addition to some custom initialization, the Create is just applied for memory, for class structure like you structure + method, the structure of the class, is equal to the declared a structure pointer to the pointer to allocate memory space,


Application space this is to know, I like my original code are all global functions, global variables I change each function to each class call big gap? Bad consciousness, I don't know how to test the performance of their classes should be more memory, the least class to save a pointer address in memory

You don't use object-oriented should be concerned about performance, object-oriented overhead, readable code maintainability, compared to this overhead is almost negligible, to put it bluntly you pursue in the wrong direction, no problem, as long as your code logic is normal, again slowly slow but also virtual machine language, such as. Net, Java, this kind of language to run there is no performance problem, so don't be alarmist, to write good code, to make the code easier to read easy maintenance, to optimize as I said above, don't use object-oriented, combined with high frequency function called in assembly, but, I have to remind you is, most people write assembly code, also can not compare with compiler,

CodePudding user response:

If you just want to finish the program clearly, don't want to create too many objects, I suggest that the last method with LZ, such calls place change is less,

CodePudding user response:

General class created, should be soon, will not be a performance bottleneck

CodePudding user response:

2 and 3,
Use need not totally depends on your design, general project will have a unit called Global put some Global variables and functions, which is called unit method, refers to the unit can use, is this, you see a lot of system function reference unit can use, rather than a class method,

CodePudding user response:

Should be ok, nothing too big difference! Basically see how to use the convenient! Impact performance is generally database operations, such as for you to create and release should be little difference between!
  • Related