[otrs-cvs] Support/Kernel/Modules AdminSupport.pm,1.7,1.8

CVS commits notifications of OTRS.org cvs-log at otrs.org
Thu May 1 16:50:48 GMT 2008


Comments:
Update of /home/cvs/Support/Kernel/Modules
In directory lancelot:/tmp/cvs-serv14893/Kernel/Modules

Modified Files:
	AdminSupport.pm 
Log Message:
Added SQL benchmark.

Author: martin

Index: AdminSupport.pm
===================================================================
RCS file: /home/cvs/Support/Kernel/Modules/AdminSupport.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** AdminSupport.pm	22 Nov 2007 13:43:52 -0000	1.7
--- AdminSupport.pm	1 May 2008 16:50:43 -0000	1.8
***************
*** 1,5 ****
  # --
  # Kernel/Modules/AdminSupport.pm - show support information
! # Copyright (C) 2001-2007 OTRS GmbH, http://otrs.org/
  # --
  # $Id$
--- 1,5 ----
  # --
  # Kernel/Modules/AdminSupport.pm - show support information
! # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
  # --
  # $Id$
***************
*** 7,11 ****
  # This software comes with ABSOLUTELY NO WARRANTY. For details, see
  # the enclosed file COPYING for license information (GPL). If you
! # did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
  # --
  
--- 7,11 ----
  # This software comes with ABSOLUTELY NO WARRANTY. For details, see
  # the enclosed file COPYING for license information (GPL). If you
! # did not receive this file, see http://www.gnu.org/licenses/gpl-2.0.txt.
  # --
  
***************
*** 247,253 ****
          # if the button send becomes the submit
          if ( $Self->{ParamObject}->GetParam( Param => "Send" ) ) {
!             my ( $s, $m, $h, $D, $M, $Y, $wd, $yd, $dst )
!                 = $Self->{TimeObject}
!                 ->SystemTime2Date( SystemTime => $Self->{TimeObject}->SystemTime(), );
              $M = sprintf( "%02d", $M );
              $D = sprintf( "%02d", $D );
--- 247,253 ----
          # if the button send becomes the submit
          if ( $Self->{ParamObject}->GetParam( Param => "Send" ) ) {
!             my ( $s, $m, $h, $D, $M, $Y, $wd, $yd, $dst ) = $Self->{TimeObject}->SystemTime2Date(
!                 SystemTime => $Self->{TimeObject}->SystemTime(),
!             );
              $M = sprintf( "%02d", $M );
              $D = sprintf( "%02d", $D );
***************
*** 286,292 ****
          # if the button download becomes the submit
          elsif ( $Self->{ParamObject}->GetParam( Param => "Download" ) ) {
!             my ( $s, $m, $h, $D, $M, $Y, $wd, $yd, $dst )
!                 = $Self->{TimeObject}
!                 ->SystemTime2Date( SystemTime => $Self->{TimeObject}->SystemTime(), );
              $M = sprintf( "%02d", $M );
              $D = sprintf( "%02d", $D );
--- 286,292 ----
          # if the button download becomes the submit
          elsif ( $Self->{ParamObject}->GetParam( Param => "Download" ) ) {
!             my ( $s, $m, $h, $D, $M, $Y, $wd, $yd, $dst ) = $Self->{TimeObject}->SystemTime2Date(
!                 SystemTime => $Self->{TimeObject}->SystemTime(),
!             );
              $M = sprintf( "%02d", $M );
              $D = sprintf( "%02d", $D );
***************
*** 314,318 ****
--- 314,463 ----
          return $Output;
      }
+     # ------------------------------------------------------------ #
+     # SQL bench
+     # ------------------------------------------------------------ #
+ 
+     elsif ( $Self->{Subaction} eq 'BenchmarkSQL' ) {
+         my $Insert = $Self->{ParamObject}->GetParam(Param => 'Insert') || 10000;
+         my $Update = $Self->{ParamObject}->GetParam(Param => 'Update') || 10000;
+         my $Select = $Self->{ParamObject}->GetParam(Param => 'Select') || 10000;
+         my $Mode = $Self->{ParamObject}->GetParam(Param => 'Mode');
+         foreach (1..$Mode) {
+             $Self->{"DBObject$_"} = Kernel::System::DB->new(%{$Self});
+         }
+         $Param{InsertTime} = 0;
+         $Param{UpdateTime} = 0;
+         $Param{SelectTime} = 0;
+         $Param{DeleteTime} = 0;
+         my $TimeStart = $Self->{TimeObject}->SystemTime();
+         $Self->_SQLInsert($Insert, $Mode);
+         my $Time1 = $Self->{TimeObject}->SystemTime();
+         $Self->_SQLUpdate($Update, $Mode);
+         my $Time2 = $Self->{TimeObject}->SystemTime();
+         $Self->_SQLSelect($Select, $Mode);
+         my $Time3 = $Self->{TimeObject}->SystemTime();
+         $Self->_SQLDelete($Insert, $Mode);
+         my $Time4 = $Self->{TimeObject}->SystemTime();
+         $Param{InsertTime} = $Param{InsertTime}+$Time1-$TimeStart;
+         $Param{UpdateTime} = $Param{UpdateTime}+$Time2-$Time1;
+         $Param{SelectTime} = $Param{SelectTime}+$Time3-$Time2;
+         $Param{DeleteTime} = $Param{DeleteTime}+$Time4-$Time3;
+         $Self->{LayoutObject}->Block(
+             Name => 'BenchmarkResult',
+             Data => {
+                 %Param,
+                 Head => 'SQL',
+             },
+         );
+         my $InsertTime = ($Param{InsertTime}/$Mode)*(10000/$Insert);
+         if ( $InsertTime <= 3 ) {
+             $Param{InsertMood} = ':-)';
+             $Param{Comment}    = '$Text{"Looks fine!"}',
+         }
+         elsif ( $InsertTime <= 5 ) {
+             $Param{InsertMood} = ':-|';
+             $Param{Comment}    = '$Text{"Ok"}';
+         }
+         else {
+             $Param{InsertMood} = ':-(';
+             my $ShouldTake  = int( $Mode * 5 );
+             $Param{Comment} = '$Text{"Should not take longer the %s on a normal system.", "' . $ShouldTake . 's"}',
+         }
+         $Self->{LayoutObject}->Block(
+             Name => 'BenchmarkResultRow',
+             Data => {
+                 Key     => 'Insert Time',
+                 Time    => "$Param{InsertTime} s $Param{InsertMood}",
+                 Value   => ($Insert*$Mode),
+                 Comment => $Param{Comment} || '',
+             },
+         );
+         my $UpdateTime = ($Param{UpdateTime}/$Mode)*(10000/$Update);
+         if ( $UpdateTime <= 5 ) {
+             $Param{UpdateMood} = ':-)';
+             $Param{Comment} = '$Text{"Looks fine!"}',
+         }
+         elsif ( $UpdateTime <= 9 ) {
+             $Param{UpdateMood} = ':-|';
+             $Param{Comment}    = '$Text{"Ok"}';
+         }
+         else {
+             $Param{UpdateMood} = ':-(';
+             my $ShouldTake  = int( $Mode * 9 );
+             $Param{Comment} = '$Text{"Should not take longer the %s on a normal system.", "' . $ShouldTake . 's"}',
+         }
+         $Self->{LayoutObject}->Block(
+             Name => 'BenchmarkResultRow',
+             Data => {
+                 Key     => 'Update Time',
+                 Time    => "$Param{UpdateTime} s $Param{UpdateMood}",
+                 Value   => ($Update*$Mode),
+                 Comment => $Param{Comment} || '',
+             },
+         );
  
+         my $SelectTime = ($Param{SelectTime}/$Mode)*(10000/$Select);
+         if ( $SelectTime <= 5 ) {
+             $Param{SelectMood} = ':-)';
+             $Param{Comment} = '$Text{"Looks fine!"}',
+         }
+         elsif ( $SelectTime <= 6 ) {
+             $Param{SelectMood} = ':-|';
+             $Param{Comment}    = '$Text{"Ok"}';
+         }
+         else {
+             $Param{SelectMood} = ':-(';
+             my $ShouldTake  = int( $Mode * 6 );
+             $Param{Comment} = '$Text{"Should not take longer the %s on a normal system.", "' . $ShouldTake . 's"}',
+         }
+         $Self->{LayoutObject}->Block(
+             Name => 'BenchmarkResultRow',
+             Data => {
+                 Key     => 'Select Time',
+                 Time    => "$Param{SelectTime} s $Param{SelectMood}",
+                 Value   => ($Select*$Mode),
+                 Comment => $Param{Comment} || '',
+             },
+         );
+ 
+         my $DeleteTime = ($Param{DeleteTime}/$Mode);
+         if ( $DeleteTime <= 4 ) {
+             $Param{DeleteMood} = ':-)';
+             $Param{Comment} = '$Text{"Looks fine!"}',
+         }
+         elsif ( $DeleteTime <= 5 ) {
+             $Param{DeleteMood} = ':-|';
+             $Param{Comment}    = '$Text{"Ok"}';
+         }
+         else {
+             $Param{DeleteMood} = ':-(';
+             my $ShouldTake  = int( $Mode * 5 );
+             $Param{Comment} = '$Text{"Should not take longer the %s on a normal system.", "' . $ShouldTake . 's"}',
+         }
+         $Self->{LayoutObject}->Block(
+             Name => 'BenchmarkResultRow',
+             Data => {
+                 Key     => 'Delete Time',
+                 Time    => "$Param{DeleteTime} s $Param{DeleteMood}",
+                 Value   => ($Insert*$Mode),
+                 Comment => $Param{Comment} || '',
+             },
+         );
+         $Self->{LayoutObject}->Block(
+             Name => 'BenchmarkResultRow',
+             Data => {
+                 Key   => 'Multiplier',
+                 Value => "* $Mode",
+             },
+         );
+         my $Output = $Self->{LayoutObject}->Header();
+         $Output .= $Self->{LayoutObject}->NavigationBar();
+         $Output .= $Self->{LayoutObject}->Output(
+             TemplateFile => 'AdminSupport',
+             Data         => \%Param,
+         );
+         $Output .= $Self->{LayoutObject}->Footer();
+         return $Output;
+     }
      # ------------------------------------------------------------ #
      # overview
***************
*** 324,327 ****
--- 469,480 ----
          # create data hash reference
          $Self->{SupportObject}->AdminChecksGet( DataHash => $DataHash, );
+         $Param{'ModeStrg'} = $Self->{LayoutObject}->OptionStrgHashRef(
+             Data => {
+                 1 => '1 * Normal (ca. 25 sek)',
+                 3 => '3 * High   (ca. 75 sek)',
+                 5 => '5 * Heavy  (ca. 125 sek)',
+             },
+             Name => 'Mode',
+         );
  
          # create & return output
***************
*** 329,333 ****
          $Output .= $Self->{LayoutObject}->NavigationBar();
  
!         $Self->{LayoutObject}->Block( Name => 'Overview', );
          for my $Module ( sort keys %{$DataHash} ) {
              $Self->{LayoutObject}->Block(
--- 482,489 ----
          $Output .= $Self->{LayoutObject}->NavigationBar();
  
!         $Self->{LayoutObject}->Block(
!             Name => 'Overview',
!             Data => \%Param,
!         );
          for my $Module ( sort keys %{$DataHash} ) {
              $Self->{LayoutObject}->Block(
***************
*** 389,391 ****
--- 545,621 ----
  }
  
+ sub _SQLInsert {
+     my $Self = shift;
+     my $Count = shift;
+     my $Mode = shift;
+     foreach my $C (1..$Count) {
+         foreach my $M (1..$Mode) {
+             my $Value1  = "aaa$C-$M";
+             my $Value2  = 'bbb';
+             $Self->{"DBObject$M"}->Do(
+                 SQL => 'INSERT INTO bench_test (name_a, name_b) values (?, ?)',
+                 Bind => [ \$Value1, \$Value2, ],
+             );
+         }
+     }
+     return 1;
+ }
+ 
+ sub _SQLUpdate {
+     my $Self = shift;
+     my $Count = shift;
+     my $Mode = shift;
+     my $Value1 = '111';
+     my $Value2 = '222';
+     foreach my $C (1..$Count) {
+         foreach my $M (1..$Mode) {
+             my $Value  = "aaa$C-$M";
+             $Self->{"DBObject$M"}->Do(
+                 SQL => 'UPDATE bench_test SET name_a = ?, name_b = ? WHERE name_a = ?',
+                 Bind => [ \$Value1, \$Value2, \$Value ],
+             );
+         }
+     }
+     return 1;
+ }
+ 
+ sub _SQLSelect {
+     my $Self = shift;
+     my $Count = shift;
+     my $Mode = shift;
+     foreach my $C (1..$Count) {
+         foreach my $M (1..$Mode) {
+ #            my $Value = "aaa$C-$M";
+ #            $Self->{"DBObject$M"}->Prepare(
+ #                SQL  => 'SELECT name_a, name_b FROM bench_test WHERE name_a = ?',
+ #                Bind => [ \$Value ],
+ #            );
+             my $Value = $Self->{DBObject}->Quote("aaa$C-$M");
+             $Self->{"DBObject$M"}->Prepare(
+                 SQL  => "SELECT name_a, name_b FROM bench_test WHERE name_a = '$Value'",
+             );
+             while (my @Row = $Self->{"DBObject$M"}->FetchrowArray()) {
+                 # do nothing
+             }
+         }
+     }
+     return 1;
+ }
+ 
+ sub _SQLDelete {
+     my $Self = shift;
+     my $Count = shift;
+     my $Mode = shift;
+     foreach my $C (1..$Count) {
+         foreach my $M (1..$Mode) {
+             my $Value  = "111$C-$M";
+             $Self->{"DBObject$M"}->Do(
+                 SQL => 'DELETE FROM bench_test WHERE name_a = ?',
+                 Bind => [ \$Value ],
+             );
+         }
+     }
+     return 1;
+ }
+ 
  1;


More information about the cvs-log mailing list