Class Diagram Based Evaluation of Software Performance Pham Van Huong and Nguyen Ngoc Binh University of Engineering and Technology Vietnam National University, Hanoi, Vietnam huongpv@gmail.com and nnbinh@vnu.edu.vn ABSTRACT The evaluation of software performance in the early stages of the software life cycle is important and it has been widely studied In the software model specification, class diagram is the important object-oriented software specification model The measures based on a class diagram have been widely studied to evaluate quality of software such as complexity, maintainability, reuse capability, etc However the software performance evaluation based on Class model has not been widely studied, especially for object-oriented design of embedded software Therefore, in this paper we propose a new approach to directly evaluate the software performance based on class diagrams From a class diagram, we determine the parameters which are used to evaluate and build formula of the measures such as Size of Class Variables, Size of Class Methods, Size of Instance Variables, Size of Instance Methods, etc Then, we analysis of the dependence of performance on these measures and build the performance evaluation function from class diagram Thereby we can choose the best class diagram based on this evaluation function Keywords: Software Performance, Software Architecture Specification, Class Diagram, Measures, SPE – Software Performance Engineering, Performance Evaluation, Performance Model INTRODUCTION Nowadays, with the strong development of software engineering, the methods and techniques specifying software architecture have been studied and widely applied The evaluating software in design time, especially in evaluating the performance has been studied by the different approaches A very good common approach is the Software Performance Engineering (SPE): based on the UML model which is added performance information to transform to the performance model from the annotated UML model [1, 15, 16 and 17] In SPE methods, designer must add the performance information to UML diagrams such as use case diagram, class diagram, activity diagram, sequence diagram, component diagram, deployment diagram, then extract information to transform into the performance model such as Queuing Network, Layered Queuing Network, Petri Net, etc and evaluate the system performance from the performance model [17, 18, 19 and 20] These studies not analyze and evaluate the software performance directly from the UML models specifying the software architecture In the UML diagrams, the class diagram is used to specifying the logical view of software architecture and it is used often when designing the object oriented software Therefore, structure of the class diagram and elements in the class diagram have the great influence on the performance and other software quality measures So in this paper we focus on analyzing the dependence of performance on the elements and the structure of the class diagram We not aim to estimate software performance from class diagram We only aim to build the performance evaluation function to able to compare and choose the class diagram which has the better performance The measures, used to evaluate software quality in the design phase based on class diagrams, given in [7-14] focus on the architecture complexity, maintenance capabilities, the reuse ability and encapsulation of software The measures are based on parameters such as the number of classes in the diagram, the number of attributes and methods of each class, the number of relationships, type of relationship among classes, inheritance depth, the overridden methods, the inheritance methods, etc However, these studies did not analyze software performance through class diagram In the research [5], authors proposed some parameters such as the number of classes in a diagram, the number of methods, the number of attributes and data types, etc and analyzed the dependence of performance on this parameter However, the authors did not describe details and neither built the performance evaluation formula directly The approach of the research [5] is also based on SPE approach International Conference on Graphic and Image Processing (ICGIP 2012), edited by Zeng Zhu, Proc of SPIE Vol 8768, 876870 · © 2013 SPIE CCC code: 0277-786X/13/$18 · doi: 10.1117/12.2008322 Proc of SPIE Vol 8768 876870-1 Downloaded From: http://proceedings.spiedigitallibrary.org/ on 05/24/2013 Terms of Use: http://spiedl.org/terms After a review of previous researches, we select the suitable parameters and analyze the dependence of performance on these parameters to build the formula of measures which affect to the software performance These measures are directly derived from class diagram and are used to construct the software performance evaluation function The rest of the paper is organized as follows: Section – analyzing the dependence of software performance on parameters in the class diagram, constructing of measures affecting to the software performance and constructing the software performance function based on these measures; Section – deployment of some experimental case studies by steps: (1) from the same application, design two different class diagram, (2) calculate the measures and the value of the performance function from two class diagrams, (3) implement two programs that are correspond to two class diagrams, (4) run two programs and evaluate the actual performance; (5) construct the performance statistic chart to check the correction of the performance function and actual performances; Section – conclusion and future work CONSTRUCTING THE SOFTWARE PERFORMANCE FUNCTION FROM THE CLASS DIAGRAM 2.1 Parameters Classes are central components in the class diagram A class is a template expressing a set of objects with the same attributes and behaviors A class diagram consists of a set of packages, classes, interfaces, relationships and constraints To construct the performance evaluation function on the class diagram, firstly we derive parameters affecting to the software performance directly from the class diagram These parameters are described in Table I TABLE I PARAMETERS USED TO EVALUATE THE SOFTWARE PERFORMANCE Parameters Class method Instance method Class variable Symbol S O Xj Instance variable Yj Method parameter Total of Classes Total of Class methods Total of Class variables Total of Instance methods Total of Instance variables Total of Parameters Size of reference variable Return data type Pk A Bi B Ci C Di D Ei E Fj r Description Is static method, that is allocated memory when loading program Is non-static method allocated memory when creating an object Is static attribute allocated memory when loading program Xj is static attribute j in a class Is non-static attribute of an object, allocated memory when creating an object Yj is non-static attribute j in an object Is parameter k of a method Number of classes in a class diagram Number of static method in the class i Number of static methods in a class diagram Number of static attributes in class i Number of static attributes in a class diagram Number of non-static methods in class i Number of non-static methods in a class diagram Number of non-static attributes in class i Number of non-static attributes in a class diagram Number of parameters in method j Every reference variable has the same size This size is equal size of a pointer tj Is return data type of method j in a class 2.2 Measures affecting to performance Before constructing the performance evaluation function from the class diagram, in this section, we focus on the analyzing components and the structure of the class diagram to build the measures affecting to software performance These measures are shown in Table II Proc of SPIE Vol 8768 876870-2 Downloaded From: http://proceedings.spiedigitallibrary.org/ on 05/24/2013 Terms of Use: http://spiedl.org/terms MEASURES AFFECTING TO PERFORMANCE TABLE II Measures Size of Class Variables Size of Class Methods Size of Executed Class Methods Size of Instance Variables Size of Instance Methods Size of Executed Instance Methods Symbol S1 Description The total of the allocated memory size of static attributes in the class diagram S2 The total of the allocated memory size of static methods in the class diagram S3 The total of the allocated memory size that will be used when executing the static methods in the class diagram The total of the allocated memory size of non-static attributes in the class diagram The total of the allocated memory size of non-static methods in the class diagram The total of the allocated memory size that will be used when executing the non-static methods in the class diagram S4 S5 S6 Size of Class Variables This measure is calculated by a total of memory amount allocated statically for all static attributes of all classes in the diagram The static elements are allocated memory once when loading the program into memory With the notation in Table I and Table II, we construct the formula for calculating the memory size total of the static attributes in the class diagram as the following formula: ܵଵ = ܵ݅ܺ(݁ݖ ) ୀଵ ୀଵ (1) Size of Class Methods The class methods are static methods, not subject to specific, commonly called by the class name and allocated once when loading the program According to the parameters in Table I and Table II, this measure is defined as formula (2): ܵଶ = ݎ ୀଵ ୀଵ (2) Size of Executed Class Methods This measure is the size of memory used when executing a static method When the static method is called, firstly the parameters are allocated and when the method done, it needs to save the returned results in memory Therefore, according to the parameters in Table I and Table II, this measure is defined as formula 3: ிೕ ܵଷ = ቌܵ݅݁ݖ൫ݐ ൯ + ܲ(݁ݖ݅ݏ )ቍ ୀଵ ୀଵ ୀଵ (3) Size of Instance Variables This measure is the method of the object and it is only allocated memory when the object is created Therefore, from the parameters in Table I and Table II, this measure is defined as formula 4: ா ܵସ = ܻܵ݅(݁ݖ ) ୀଵ ୀଵ Proc of SPIE Vol 8768 876870-3 Downloaded From: http://proceedings.spiedigitallibrary.org/ on 05/24/2013 Terms of Use: http://spiedl.org/terms (4) Size of Instance Methods Instance methods are non-static method, allocated memory when creating the object and only used after creating the object Therefore, according to the parameters in Table I and Table II, this measure is defined as formula (5): ܵହ = ݎ ୀଵ ୀଵ (5) Size of Executed Instance Methods This measure is the total of memory size used when executing the instance methods It includes the allocated memory for parameters and the memory containing the returned result of the instance method According to the parameters in Table I and Table II, this measure is defined as formula (6): ிೕ ܵ = ቌܵ݅݁ݖ൫ݐ ൯ + ܲ(݁ݖ݅ݏ )ቍ ୀଵ ୀଵ ୀଵ (6) 2.3 Performance evaluation function To construct the performance evaluation function from the class diagram, we analyze the allocating and accessing memory in the execution of an objected oriented program When executing the program, firstly class source will be loaded into memory, the static components including class variables and class methods are also allocated memory in the load time Thus, to use the static components only need one time for allocating memory statically and once accessing memory When using the instance variables and the instance methods of the object, the object should be created When creating objects, need to perform two steps such as fetching and executing the statement that used to create an object, and dynamically allocating memory for the instance variables and instance methods of the object Therefore it needs once times for allocating and two times for accessing memory to be able to use the components of the object When executing the class method, it needs once accessing memory to point to the code memory of the method, and needs once allocating memory for the parameters of the method, and needs once accessing the memory containing returned data after executing the method Also, to call the static method should access to class code held in memory so it requires at least once allocating memory and three accessing memory to execute the static At the design level, in the class diagram, we not care and cannot evaluate the source code of the method Before executing the instance method, we must create the object firstly, and because the instance method is called by object name, so it require at least once allocating memory and two accessing memory to be able to call the instance method After creating the object containing the instance method, the executing process of the instance method is similar to the executing of the class method So the whole executing process of the instance method requires at least two memory allocation operations and five memory access operations In the design phase, the software performance cannot be evaluated with the absolute accurately Furthermore, the purpose of the performance evaluation function is the selecting the class diagram that will have better performance Therefore, to evaluate performance from the class diagram, we assume a memory allocation operation statically or dynamically and a memory access operation are the same and equal a time unit (mini second) And the performance is also the execution time of the program The performance evaluation function is denoted by Fp and is calculated by the formula (7) based on the measures from formula (1) - (6) Fp = 2*(S1 + S2) + 4*S3 + 3*(S4 + S5) + 7*S6 (7) EXPERIMENT In this section, we did three experiments to verify the performance evaluation function In each case study, we build an application following two stages: designing class diagram and implementation In the design phase, an application is designed by two different class diagrams showing two logical architecture of the software We calculate the measures by the formula (1) - (6) and the value of the performance evaluation function to select the better architecture In the implementation phase, class diagrams are implemented into different programs These programs are executed on the same environment to evaluate performance To avoid the influence of the implementation of a method to the performance evaluation, the source code executing the same task are similar This illustrates the same algorithm, the same source code, but different architectures also affect to software performance Finally, we check the Proc of SPIE Vol 8768 876870-4 Downloaded From: http://proceedings.spiedigitallibrary.org/ on 05/24/2013 Terms of Use: http://spiedl.org/terms conformity between the comparison of performance from class diagrams and the comparison of realistic performances This aims to verify the correctness of the evaluation function and measures In the all of three case studies we conduct following the steps: (step 1) design two class diagrams of the same application, identifying parameters, measures and calculate values of the performance evaluation function from the two class diagrams; (step 2) implement two programs from two class diagrams, execute the program in 10 times and calculate the average actual performance; (step 3) draw chart to compare the results that are evaluated from the class diagrams with actual results Excution time (m5( 865 900 800 622 Class Diagram 700 600 _ _ 500 400 300 200 100 e (Performance form - I1 430.6 Class Diagram 404.4 (Actual performance) class digram( Figure Compare the performance level model and the actual performance Case study: Han-Nom character recognition Nom character recognition system is researched and developed in Laboratory of Embedded System, University of Engineering and Technology, Vietnam National University, Hanoi [21, 22] This recognition system consists three major phases: pre-processing, training and recognition To verify the measures and the performance evaluation function, in this case study we focus on the recognition module Firstly, we design Han-Nom character recognition by two different class diagram shown Figure and Figure Then, we evaluate performance from two class diagram by formula (1) - (7) After designing the Han-Nom character recognition module into two different class diagrams, we implement two programs respectively Source code and algorithms in a method are almost the same in both two programs The two programs only differ in elements, type of element and organization of elements described in the two diagrams Class Then, we run each program 10 times on the same configuration and calculate the average execution time Finally, we construct the performance chart to compare the performances calculating from class diagram and actual performances such as shown in Figure In this figure, the performance value which is evaluated from model of class diagram is greater than that of class diagram And the actual performance of the program which implements the class diagram is greater that of the program Thus, the results of the evaluation function are right CONCLUSION AND FUTURE WORK In summary, this paper has the following main contributions The first we presented a new method to evaluate software performance during design phase based on the structure and components in the class diagram We have analyzed and constructed measures that are derived directly from the class diagram, evaluated the dependence of performance on these measures for building performance evaluation function The performance evaluation method in this paper is new approach compared with the SPE method because we have directly evaluated the performance from the class diagram The second formulas and the evaluation function have been checked by our experiments However, this research only focuses on the major components affecting to performance without analyzing factors affecting to software quality such as inheritance, relationships, type of relationship, interfaces and packages Proc of SPIE Vol 8768 876870-5 Downloaded From: http://proceedings.spiedigitallibrary.org/ on 05/24/2013 Terms of Use: http://spiedl.org/terms This study is background for further researches such as optimizing software level design and checking model Based on this research, we will study software optimization methods level design such as Pareto multi-objective optimization for embedded software and optimizing software performance based on model transformation ACKNOWLEDGMENTS This research is partly supported NAFOSTED and also by a VNU scientific project (group A) for 2012-2013 REFERENCES [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] Lloyd G Williams “Performance Evaluation of Software Architectures”, 1-12, (1998) Connie U Smith, Catalina M Lladó, Vittorio Cortellessa and Lloyd G Williams, “From UML models to software performance results: An SPE process based on XML interchange formats”, 1-13, (2005) Dorin B Petriu, Murray Woodside, “A Metamodel for Generating Performance Models from UML Designs”, Dept of Systems and Computer Engineering Carleton University, Ottawa K1S 5B6, Canada, 1-11, (2003) Simonetta Balsamo Moreno Marzoll, “Efficient Performance Models in Component-Based Software Engineering”, Di Informatica, Universit`a Ca’ Foscari di Venezia, via Torino 155, Italy, 1-10, (2006) Ahmad Alsaadi, “Applying the UML Class Diagram in the Performance Analysis”, Department of Informatics and Computers Engineering University of Damascus, Syria, 1-18,( 2005) Gail C Murphy and Ekaterina Saenko, “Predicting Memory Use from a Class Diagram using Dynamic Information”, Department of Computer Science, Vancouver B.C Canada V6T 1Z4, 1-9, (2005) Marcela Genero, Mario Piattini and Coral Calero, “Early measures for UML class diagrams”, ALARCOS Research Group Department of Computer Science University of Castilla - Ciudad Real – SPAIN, 3-10, (2001) Marcela Genero, “A Survey of Metrics for UML Class Diagrams, University of Castilla-La Mancha”, Spain Mario Piattini, JOURNAL OF O BJECT TECHNOLOGY, published by ETH Zurich, 235-243, (2005) Tong Yi, Fangjun Wu, Chengzhi Gan, “A Comparison of Metrics for UML Class Diagrams, Department of Computer Science & Engineering”, Southeast University, Nanjing, 210096, China, 126-132, (2004) Esperanza Manso, Marcela Genero , Mario Piattini, “No-Redundant Metrics for UML Class Diagram Structural Complexity”, Deparment of Computer Science, University of Valladolid - Valladolid – Spain, Department of Computer Science, University of Castilla-La Mancha - Ciudad Real – Spain, 25-30, (2007) Kim, S., Barry, “UML-based object-oriented metrics for architecture complexity analysis”, Department of computer science, Texas A&M University, 243-250, (2003) Kang, D., et al (2004), “A structural complexity measure for UML class diagrams”, International Conference on Computational Science, Krakow Poland, 431-435, (2004) Marchesi, M., “OOA metrics for the unified modeling languages, Proceedings of 2nd Euromicro Conference on Software Maintenance and Reengineering”, Palazzo degli Affari, Italy, March, 67-73, (1998) Genero, M., Olivas, J., Piattini, Romero, “Using metrics to predict OO information sy stems maintainability”, Proceedings of CAiSE, Interlaken, Switzerland, Lecture Notes in Computer Science, 388-401, (2001) D.A Menascè, H Gomaa, “On a Language Based Method for Software Performance Engineering of Client/Server Systems”, Proc of WOSP'98, Santa Fe, New Mexico, USA, 63-69, (1998) S Balsamo, P Inverardi, C Mangano, “An Approach to Performance Evaluation of Software Architectures Workshop on Software and Performance”, WOSP'98, Santa Fe, New Mexico, 12-16, (1998) V Cortellessa, R Mirandola, “Deriving a Queueing Network based Performance Model from UML Diagrams”, WOSP, 325-340, (2000) M Bernardo, P Ciancarini, “A Process Algebraic Description Language for the Performance Analysis of Software Architectures”, WOSP, 115-120, (2000) F Aquilani, S Balsamo, P Inverardi, “Performance Analysis at the software architecture design level”, Technial Report TR-SAL-32, Technical Report Saladin Project, 55-62, (2000) F Andolfi, F Aquilani, S Balsamo, P Inverardi, “Deriving Performance Models of Software Architectures from Message Sequence Charts”, ACM Press, 47-57, (2000) P.V Huong, T.M Tuan, N.N Binh, T.A Hoang, “Some Approaches to Nôm Optical Character Recognition”, VNU, Hanoi J of Science, Natural Sciences and Technology, Vol 24, No 3S, 90-99, (2008) P.V Huong, N.N Binh, T.M Tuan, N.T.N Huong, L.T Trang, V.T Nhan, T.A Hoang, “Some Methodologies of Nôm Optical Character Recognition”, Proceedings of ICT.rda'08, 309-318, (2008) Proc of SPIE Vol 8768 876870-6 Downloaded From: http://proceedings.spiedigitallibrary.org/ on 05/24/2013 Terms of Use: http://spiedl.org/terms ... static attributes in class i Number of static attributes in a class diagram Number of non-static methods in class i Number of non-static methods in a class diagram Number of non-static attributes... model of class diagram is greater than that of class diagram And the actual performance of the program which implements the class diagram is greater that of the program Thus, the results of the evaluation. .. non-static attribute j in an object Is parameter k of a method Number of classes in a class diagram Number of static method in the class i Number of static methods in a class diagram Number of static