OpenModelica Users Guide Version 2012-03-29


Chapter 9 Modelica Performance Analyzer



Download 0.95 Mb.
Page17/23
Date28.01.2017
Size0.95 Mb.
#9043
1   ...   13   14   15   16   17   18   19   20   ...   23

Chapter 9

Modelica Performance Analyzer


A common problem when simulating models in an equation-based language like Modelica is that the model may contain non-linear equation systems. These are solved in each time-step by extrapolating an initial guess and running a non-linear system solver. If the simulation takes too long to simulate, it is useful to run the performance analysis tool. The tool has around 5~25% overhead, which is very low compared to instruction-level profilers (30x-100x overhead). Due to being based on a single simulation run, the report may contain spikes in the charts.

When running a simulation for performance analysis, execution times of user-defined functions as well as linear, non-linear and mixed equation systems are recorded.

To start a simulation in this mode, just use the measureTime flag of the simulate command.

simulate(modelname, measureTime = true)

The generated report is in HTML format (with images in the SVG format), stored in a file modelname_prof.html, but the XML database and measured times that generated the report and graphs are also available if you want to customize the report for comparison with other tools.

Below we use the performance profiler on the simple model A:

model A

function f

input Real r;

output Real o := sin(r);

end f;

String s = "abc";

Real x = f(x) "This is x";

Real y(start=1);

Real z1 = cos(z2);

Real z2 = sin(z1);



equation

der(y) = time;



end A;

We simulate as usual, but set measureTime=true to activate the profiling:



simulate(A, measureTime = true)
// // record SimulationResult

// resultFile = "A_res.mat",

// messages = "Time measurements are stored in A_prof.html (human-readable) and A_prof.xml (for XSL transforms or more details)"

// end SimulationResult;

9.1Example Report Generated for the A Model

9.1.1Information


All times are measured using a real-time wall clock. This means context switching produces bad worst-case execution times (max times) for blocks. If you want better results, use a CPU-time clock or run the command using real-time priviliges (avoiding context switches).

Note that for blocks where the individual execution time is close to the accuracy of the real-time clock, the maximum measured time may deviate a lot from the average.



For more details, see the generated file A_prof.xml, shown in Section 9.1.7 below.

9.1.2Settings


The settings for the simulation are summarized in the table below:


Name

Value

Integration method

euler

Output format

mat

Output name

A_res.mat

Output size

24.0 kB

Profiling data

A_prof.data

Profiling size

27.3 kB

9.1.3Summary


Execution times for different activities:


Task

Time

Fraction

Pre-Initialization

0.000401

19.17%

Initialization

0.000046

2.20%

Event-handling

0.000036

1.72%

Creating output file

0.000264

12.62%

Linearization

0.000000

0.00%

Time steps

0.001067

51.00%

Overhead

0.000273

13.05%

Unknown

0.000406

0.24%

Total simulation time

0.002092

100.00%

9.1.4Global Steps


 

Steps

Total Time

Fraction

Average Time

Max Time

Deviation



499

0.001067

51.00%

2.13827655310621e-06

0.000006611

2.09x

9.1.5Measured Function Calls


 

Name

Calls

Time

Fraction

Max Time

Deviation



A.f

1506

0.000092990

4.45%

0.000000448

6.26x

9.1.6Measured Blocks


 

Name

Calls

Time

Fraction

Max Time

Deviation



residualFunc3

2018

0.000521137

24.91%

0.000035456

136.30x



residualFunc1

1506

0.000393709

18.82%

0.000002735

9.46x

9.1.6.1Equations


Name

Variables

SES_ALGORITHM 0

 

SES_SIMPLE_ASSIGN 1

der(y)

residualFunc3

z2, z1

residualFunc1

x

9.1.6.2Variables


Name

Comment

y

 

der(y)

 

x

This is x

z1

 

z2

 

s

 

9.1.7Genenerated XML for the Example

-

-

A

A


2011-03-07 12:55:53

euler

mat

A_res.mat

24617

0.000273

0.000401



0.000046

0.000036

0.000264

0.000000

0.002092

0.001067

499

0.000006611

-


A_prof.data

28000

-



step

time

cpu time

A.f (calls)

residualFunc3 (calls)

residualFunc1 (calls)

A.f (cpu time)

residualFunc3 (cpu time)

residualFunc1 (cpu time)


-

-





-





-





-





-





-







-

-

A.f

1506



0.000000448





-

-



-

-





-

-







-

-







-


-




2018



0.000035456
-




1506



0.000002735





Download 0.95 Mb.

Share with your friends:
1   ...   13   14   15   16   17   18   19   20   ...   23




The database is protected by copyright ©ininet.org 2024
send message

    Main page