Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_testmemory.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * List Animal
9  *
10  * @author Anakeen 2008
11  * @version $Id: zoo_animallist.php,v 1.1 2008/02/26 13:34:14 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  *
15  * @global docid Http var : document identificator
16  * @global newname Http var : new animal name
17  /**
18  */
19 
20 include_once ("FDL/Class.Doc.php");
21 include_once ("FDL/Class.SearchDoc.php");
22 
23 $usage = "usage --mode=>[TABLE|OBJECT|ITEM]> --famid=<family idenificator> --slice=<number od document to retrieve>";
24 
25 $dbaccess = $appl->GetParam("FREEDOM_DB");
26 if ($dbaccess == "") {
27  print "Database not found : param FREEDOM_DB";
28  exit;
29 }
30 
31 $mode = (GetHttpVars("mode"));
32 if (($mode != 'TABLE') && ($mode != 'OBJECT') && ($mode != 'ITEM')) $action->exitError("mode needed :\n $usage");
33 
34 $FD = array();
35 
36 $family = GetHttpVars("famid");
37 $slice = GetHttpVars("slice", 10);
38 $s = new SearchDoc($dbaccess, $family);
39 $s->slice = $slice;
40 $s->orderby = 'id desc';
41 //$s->setDebugMode();
42 $t = $s->search();
43 //print_r2($s->getDebugInfo());
44 foreach ($t as $v) $ids[] = $v["id"];
45 
46 $time_start = microtime(true);
47 $memory_start = memory_get_usage();
48 foreach ($ids as $id) {
49  if ($mode == "OBJECT") $d = new_doc($dbaccess, $id);
50  if ($mode == "ITEM") {
51  $d = getDocObject($dbaccess, getTdoc($dbaccess, $id));
52  } else $d = getTdoc($dbaccess, $id);
53  $stat[$id] = array(
54  "memory" => memory_get_usage() ,
55  "time" => microtime(true)
56  );
57  if (is_array($d)) $tf[$d["fromid"]] = $d["fromid"];
58  else $tf[$d->fromid] = $d->fromid;
59 }
60 
61 $time_end = microtime(true);
62 $memory_end = memory_get_usage();
63 
64 $lmem = $memory_start;
65 $ltime = $time_start;
66 foreach ($stat as $id => $v) {
67  // printf("%3d | %3dKo | %3dms |\n",$id, ($v["memory"] - $lmem)/1024, ($v["time"] - $ltime)*1000);
68  $lmem = $v["memory"];
69  $ltime = $v["time"];
70 }
71 
72 printf("TOT (%6s) | %3dKo | %3dms | DFAM=%s,CARD=%d,MOY=%3dms\n", $mode, ($memory_end - $memory_start) / 1024, ($time_end - $time_start) * 1000, count($tf) , count($ids) , ($time_end - $time_start) * 1000 / count($ids));
73 return;
74 ?>
← centre documentaire © anakeen - published under CC License - Dynacase