• No results found

Databases and Information Systems II

N/A
N/A
Protected

Academic year: 2021

Share "Databases and Information Systems II"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

Databases and

Information Systems II

Performance evaluation

Profiling

2/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Performance evaluation

 New compression approach must be competible in terms of  Compression ratio

 Compression time  Decompression time  Query evaluation time  …

 Slow performance can be caused by  Slow algorithms

(2)

3/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Performance evaluation - currentTimeMillis()

String ret= ""; int runs = 10; int dur = 0;

for (int rep = 0; rep < runs; rep++) { long start = System.currentTimeMillis(); for (int i = 0; i < 1000; i++) {

ret += i; }

dur += (System.currentTimeMillis() - start); }

System.out.println("String: " + (dur/runs) + " ms"); > String: 86 ms

> StringBuffer: 0 ms > StringBuilder: 0 ms

Performance evaluation – nanoTime()

String ret= ""; int runs = 10; int dur = 0;

for (int rep = 0; rep < runs; rep++) { long start = System.nanoTime(); for (int i = 0; i < 1000; i++) {

ret += i; }

dur += (System.nanoTime() - start); }

System.out.println("String: " + (dur/runs) + " ns"); > String: 89426463 ns

> StringBuffer: 335929 ns > StringBuilder: 169903 ns

(3)

5/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Wall clock, User, System, and CPU time

 Wall clock time:

 Real-world time, while the user waits the system to be finished  System.nanoTime(), System.currentTimeMillis()

 User time:

 Time spent running the application’s code  System time:

 Time spent running OS code caused by your application (e.g. I/O)  CPU time:

 User time + System time; Total time spent using CPU for your application

6/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Wall clock, User, System, and CPU time

 Wall clock time:

 Real-world time, while the user waits the system to be finished  System.nanoTime(), System.currentTimeMillis()

 User time:

 Time spent running the application’s code  System time:

 Time spent running OS code caused by your application (e.g. I/O)  CPU time:

 User time + System time; Total time spent using CPU for your application

import java.lang.management public long getCpuTime( ) {

ThreadMXBean bean = ManagementFactory.getThreadMXBean(); if(bean.isCurrentThreadCpuTimeSupported( ))

return bean.getCurrentThreadCpuTime( ); else return 0L;

}

public long getUserTime( ) {

ThreadMXBean bean = ManagementFactory.getThreadMXBean(); if(bean.isCurrentThreadCpuTimeSupported( ))

return bean.getCurrentThreadUserTime( ); else return 0L;

}

public long getSystemTime( ) {

ThreadMXBean bean = ManagementFactory.getThreadMXBean(); if(bean.isCurrentThreadCpuTimeSupported( ))

return (bean.getCurrentThreadCpuTime( )

-bean.getCurrentThreadUserTime( )); else return 0L;

(4)

7/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Performance evaluation

 Performance time is influenced by  Operating system processes  Other processes

 Tasks of Virtual Machine (e.g. garbage collection)  Perform redundant measurements (> 10 runs)

 System.currentTimeMillis() and System.nanoTime(), CPU, User and System time

 Simple to use

 Good for comparing different approaches

 Not very convenient for finding performance bottlenecks  Use Profiler instead

Profiling

 Java Profiler  JAMon (http://jamonapi.sourceforge.net/)  JIP (http://sourceforge.net/projects/jiprof/)  TPTP (http://www.eclipse.org/tptp/)  …

A profiler is a performance analysis tool that measures

the behavior of a program as it executes, particularly

the frequency and duration of function calls.

(5)

9/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Profiling – JAMon

String ret = "";

Monitor monString = null;

for (int rep = 0; rep < 10; rep++) { MonitorFactory.start("String"); for (int i = 0; i < 1000; i++) {

ret += i; }

monString.stop(); }

String html = MonitorFactory.getReport();

Label Hits Avg Total StdDev Last Min Max … StringBuffer 10.0 0.4 4.0 0.516 0.0 0.0 1.0

StringBuilder10.0 0.1 1.0 0.316 0.0 0.0 1.0

String 10.0 11.4 114.0 5.059 9.0 7.0 23.0

10/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Profiling – JAMon

 Advantages

 Convenient to use

 Independent of platform and IDE  Any granularity

 Especially easy to use for web and database applications  Disadvantages

(6)

11/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Profiling – JIP (Java Interactive Profiler)

+---| Thread: 1

+---Time Percent --

---Count Total Net Total Net Location ===== ===== === ===== === ========= 1 457,6 5,5 100,0 1,2 +--Main:main () 1 446,1 446,1 97,5 97,5 | +--Main:testString () 1 5,2 5,2 1,1 1,1 | +--Main:testStringBuffer () 1 0,7 0,7 0,2 0,2 | +--Main:testStringBuilder ()

> java –javaagent:path/profiler.jar Main

Profiling – JIP (Java Interactive Profiler)

 Advantages  Easy to use  Efficient to use

 Independent of platform and IDE

 Disadvantages

 Not very convenient to analyze the results  Finest granularity: Methods

(7)

13/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Profiling – TPTP

Eclipse Menu

Run

Profile

Configurations…

14/14 Databases and Information Systems II – SS 11 – Performance evaluation and Profiling

Profiling – TPTP

 Advantages

 Convenient to use

 No changes in program code  GUI allows detailed analysis  Disadvantages

 Eclipse plugin (dependent on Eclipse)  Finest granularity: Methods

References

Related documents

The distinction regarding whether provision of fluids and nutrition is a medical procedure is important lawfully and morally because a patient does have the right to

To protect this alternate point of entry, which leads deep into the dungeon complex, the priests of Orcus erected a dark temple on the surface (see the Wilderness Area 3

Review Exit Criteria Evidence of Feasibility validated Feasibility shortfalls identified as risks, covered by risk mitigation plans Stakeholder agreement on review

INCIDENCE OF DENTAL CARIES IN TUBE-FED CHILDREN AND TUBE- FED CHILDREN RECEIVING ORAL FEEDING THERAPY: A..

Rather the uncanny silence/absence de-faced by but intuitable in the lyric poem is in the nature of (at home in) the lyric poem as much as it is in the robot voice,

Climate change has the power to affect many ecological processes, but the most obvious changes ap- pear in the form of melting sea ice, sea level rise, changes in oceanic

This paper show the results of a study conducted with employees of the private banking sector in Albania, and shows that employees of this sector are more motivated by monetary

Inflation has a significant positive effect on company profitability, GDP does not have a significant positive effect on profitability, capital structure has