3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.cdm
.io
.common
;
13 import org
.apache
.log4j
.Logger
;
14 import org
.joda
.time
.DateTime
;
15 import org
.joda
.time
.Duration
;
16 import org
.joda
.time
.ReadableDuration
;
24 public class PartitionerProfiler
{
25 private static final Logger logger
= Logger
.getLogger(PartitionerProfiler
.class);
27 ResultSetPartitioner partitioner
;
29 DateTime startTx
= new DateTime();
30 DateTime startRs
= new DateTime();
31 DateTime startRelObjects
= new DateTime();
32 DateTime startRS2
= new DateTime();
33 DateTime startDoPartition
= new DateTime();
34 DateTime startDoSave
= new DateTime();
35 DateTime startDoCommit
= new DateTime();
36 DateTime end
= new DateTime();
38 private Duration durTxStartAll
= new Duration(0, 0);
39 private Duration durPartitionRs1All
= new Duration(0, 0);
40 private Duration durRelObjectsAll
= new Duration(0, 0);
41 private Duration durPartitionRs2All
=new Duration(0, 0);
42 private Duration durPartitionAll
= new Duration(0, 0);
43 private Duration durTxCommitAll
= new Duration(0, 0);
44 private Duration durSaveAll
= new Duration(0, 0);
47 private ReadableDuration durTxStartSingle
;
48 private ReadableDuration durPartitionRs1Single
;
49 private ReadableDuration durRelObjectsSingle
;
50 private ReadableDuration durPartitionRs2Single
;
51 private ReadableDuration durPartitionSingle
;
52 private ReadableDuration durSaveSingle
;
53 private ReadableDuration durTxCommitSingle
;
55 public void startTx(){
56 startTx
= new DateTime();
60 public void startRs(){
61 startRs
= new DateTime();
62 durTxStartSingle
= new Duration(startTx
, startRs
);
63 durTxStartAll
= durTxStartAll
.withDurationAdded(durTxStartSingle
, 1);
66 public void startRelObjects(){
67 startRelObjects
= new DateTime();
68 durPartitionRs1Single
= new Duration(startRs
, startRelObjects
);
69 durPartitionRs1All
= durPartitionRs1All
.withDurationAdded(durPartitionRs1Single
, 1);
72 public void startRs2(){
73 startRS2
= new DateTime();
74 durRelObjectsSingle
= new Duration(startRelObjects
, startRS2
);
75 durRelObjectsAll
= durRelObjectsAll
.withDurationAdded(durRelObjectsSingle
, 1);
78 public void startDoPartition(){
79 startDoPartition
= new DateTime();
80 startDoSave
= new DateTime();
81 durPartitionRs2Single
= new Duration(startRS2
, startDoPartition
);
82 durPartitionRs2All
= durPartitionRs2All
.withDurationAdded(durPartitionRs2Single
, 1);
85 public void startDoSave(){
86 startDoSave
= new DateTime();
87 //durSaveSingle = new Duration(startRS2, startSave);
88 //durPartitionRs2All = durPartitionRs2All.withDurationAdded(durPartitionRs2Single, 1);
91 public void startDoCommit(){
92 startDoCommit
= new DateTime();
93 durPartitionSingle
= new Duration(startDoPartition
, startDoCommit
);
94 durPartitionAll
= durPartitionAll
.withDurationAdded(durPartitionSingle
, 1);
95 durSaveSingle
= new Duration(startDoSave
, startDoCommit
);
96 durSaveAll
= durSaveAll
.withDurationAdded(durSaveSingle
, 1);
100 end
= new DateTime();
101 durTxCommitSingle
= new Duration(startDoCommit
, end
);
102 durTxCommitAll
= durTxCommitAll
.withDurationAdded(durTxCommitSingle
, 1);
106 if (logger
.isDebugEnabled()){
107 System
.out
.println("Durations: " +
108 "Start Transaction: " + durTxStartSingle
.getMillis() + "/" + durTxStartAll
.getMillis() +
109 "; partitionRS1: " + durPartitionRs1Single
.getMillis() + "/" + durPartitionRs1All
.getMillis() +
110 "; getRelatedObjects: " + durRelObjectsSingle
.getMillis() + "/" + durRelObjectsAll
.getMillis() +
111 "; partitionRS2 " + durPartitionRs2Single
.getMillis() + "/" + durPartitionRs2All
.getMillis() +
112 "; doPartition " + durPartitionSingle
.getMillis() + "/" + durPartitionAll
.getMillis() +
113 "; doSave " + durSaveSingle
.getMillis() + "/" + durSaveAll
.getMillis() +
114 "; commit " + durTxCommitSingle
.getMillis() + "/" + durTxCommitAll
.getMillis()