1 package com.soebes.maven.extensions.artifact;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.text.NumberFormat;
23 import java.util.Map.Entry;
24
25 import org.slf4j.Logger;
26 import org.slf4j.LoggerFactory;
27
28 import com.soebes.maven.extensions.TimePlusSize;
29
30
31
32
33 public class InstallTimer
34 extends AbstractArtifactTimer
35 {
36 private final Logger LOGGER = LoggerFactory.getLogger( getClass() );
37
38 public InstallTimer()
39 {
40 super();
41 }
42
43 public void report()
44 {
45 if ( getTimerEvents().isEmpty() )
46 {
47 return;
48 }
49 LOGGER.info( "Installation summary:" );
50 long totalInstallationTime = 0;
51 long totalInstallationSize = 0;
52 for ( Entry<String, TimePlusSize> item : this.getTimerEvents().entrySet() )
53 {
54 totalInstallationTime += item.getValue().getElapsedTime();
55 totalInstallationSize += item.getValue().getSize();
56 LOGGER.info( "{} ms : {}", String.format( "%8d", item.getValue().getElapsedTime() ), item.getKey() );
57 }
58
59 double mibPerSeconds = calculateMegabytesPerSeconds( totalInstallationTime, totalInstallationSize );
60 LOGGER.info( "{} ms {} bytes. {} MiB / s", NumberFormat.getIntegerInstance().format( totalInstallationTime ),
61 NumberFormat.getIntegerInstance().format( totalInstallationSize ),
62 NumberFormat.getNumberInstance().format( mibPerSeconds ) );
63 LOGGER.info( "------------------------------------------------------------------------" );
64 }
65
66 }