From 7ca61f1855b531321240aa60cdf6a51206342d3a Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 27 Jan 2006 08:57:26 +0000 Subject: [PATCH] Added print_red if, ldapsearch ttooks too long git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2592 594d385d-05f5-0310-b6e9-bd551577e9d8 --- include/class_ldap.inc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/include/class_ldap.inc b/include/class_ldap.inc index d83e1b7a6..20ff04037 100644 --- a/include/class_ldap.inc +++ b/include/class_ldap.inc @@ -129,7 +129,8 @@ class LDAP{ function search($filter, $attrs= array()) { - + $start = microtime(); + if($this->hascon){ if ($this->reconnect) $this->connect(); $this->clearResult(); @@ -137,6 +138,31 @@ class LDAP{ $this->error = @ldap_error($this->cid); $this->resetResult(); $this->hasres=true; + + /* Time management */ + $r = split(" ",$start); + $ms = $r[0]; + $s= $r[1]; + + $re = split(" ",microtime()); + $mse = $re[0]; + $se= $re[1]; + + $add = 0; + if(($mse -$ms)<0){ + $se --; + $add = 1; + } + $secs = ($se -$s); + $msecs = (int)(($add+($mse -$ms))*1000); + $time = $secs +($msecs/1000); + if($time > .2){ + $Sattrs = ""; + foreach($attrs as $att){ + $Sattrs .= " ".$att; + } + print_red(sprintf(_("Ldap search took about %s seconds, used filter '%s' with following attributes '%s '. Please check for performance improvements."),$time,htmlentities($filter),$Sattrs)); + } return($this->sr); }else{ $this->error = "Could not connect to LDAP server"; -- 2.30.2