Welcome to mirror list, hosted at ThFree Co, Russian Federation.

generateVisits.php « misc - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 15890729a93581c735ca11af0b8b68cb8dabb833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php

error_reporting(E_ALL|E_NOTICE);
define('PIWIK_INCLUDE_PATH', '..');
define('PIWIK_DATAFILES_INCLUDE_PATH', PIWIK_INCLUDE_PATH . "/modules/DataFiles");

ignore_user_abort(true);
set_time_limit(0);

set_include_path(PIWIK_INCLUDE_PATH 
					. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/libs/'
					. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/plugins/'
					. PATH_SEPARATOR . PIWIK_INCLUDE_PATH . '/modules'
					. PATH_SEPARATOR . get_include_path() );

require_once "Event/Dispatcher.php";
require_once "Common.php";
require_once "PluginsManager.php";

require_once "LogStats.php";
require_once "LogStats/Config.php";
require_once "LogStats/Action.php";
require_once "LogStats/Cookie.php";
require_once "LogStats/Db.php";
require_once "LogStats/Visit.php";

$GLOBALS['DEBUGPIWIK'] = false;

require_once "Timer.php";
require_once "LogStats/Generator.php";

ob_start();
Piwik_PluginsManager::getInstance()->doNotLoadPlugins();	
$generator = new Piwik_LogStats_Generator;
$generator->setMaximumUrlDepth(2);
//$generator->disableProfiler();
//$generator->emptyAllLogTables();
$generator->init();

$t = new Piwik_Timer;

/*
 * Generate visits / actions for the last 31 days
 */
$daysToCompute = 10;
$startTime = time() - ($daysToCompute-1)*86400;
$nbActionsTotal = 0;
while($startTime <= time())
{
	$visits = rand(1,2);
	$actions = 10;
	$visits = rand(10,30);
	$actions = 5;
	
	$generator->setTimestampToUse($startTime);
	$nbActionsTotalThisDay = $generator->generate($visits,$actions);
	
	$actionsPerVisit = round($nbActionsTotalThisDay / $visits);
	print("Generated $visits visits and $actionsPerVisit actions per visit for the ".date("Y-m-d", $startTime)."<br>\n");
	$startTime+=86400;
	$nbActionsTotal+=$nbActionsTotalThisDay;
}


echo "<br>Total actions: $nbActionsTotal";
echo "<br>Total requests per sec: ". round($nbActionsTotal / $t->getTime(),0);
echo "<br>".$t;

$generator->end();

ob_end_flush();
?>