-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
146 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
define("APP_DIR", __DIR__); | ||
include dirname(__DIR__)."/init.php"; // project init | ||
|
||
\hb\HB::dispatch(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
namespace app1\action; | ||
|
||
/* | ||
* Sample Nested and Deep Profiling Example | ||
**/ | ||
|
||
class Profiler extends \hb\Action { | ||
|
||
# uri: /profiler/ | ||
function index() { | ||
echo "<h1>Complex Profiling Example</h1>"; | ||
|
||
$API_KEY = \hb\Str::random(6); | ||
iprofiler()->in("api-call-wrapper", ["api-params" => 'outter api call'], ['api' => $API_KEY, 'style' => 'hide']); | ||
iprofiler()->api("api-call", ["api-params"]); | ||
iprofiler()->info("opts[link] + args[0]", ['arg[0] text', 'a' => 'A'], ['link' => '/url/', 'edit' => '/xxx']); | ||
iprofiler()->inHide("in and hide", ['text'], ['details' => '/url/', 'edit' => '/xxx']); | ||
iprofiler()->api("api-call internal", ["api-params 2"]); | ||
usleep(60200); | ||
$a = str_repeat("xxx", 400000); | ||
iprofiler()->out(['arg-in-out' => "a"]); | ||
unset($a); | ||
iprofiler()->out(['arg-in-out' => "b"]); | ||
|
||
|
||
$x = new XXX_Very_Very_Long_ClassName(); | ||
$x->veryVeryLong_Method__Name("a", [1,2,3], "b", str_repeat("abC-", 22), $_SERVER); | ||
unset($P); | ||
|
||
|
||
return 0; | ||
} | ||
|
||
} | ||
|
||
|
||
function A_Project($callable, ...$args) { | ||
return $callable(...$args); | ||
} | ||
|
||
class XXX_Very_Very_Long_ClassName { | ||
|
||
function veryVeryLong_Method__Name($a, $b, $c, $d) { | ||
return A_Project("XXX_Very_Very_Long_ClassName::methodName", $b, [$a, [$c, $d]]); | ||
} | ||
|
||
static function methodName($param1, &$param2, $deep = 0) { | ||
$P = profiler(__FUNCTION__, $param1); | ||
hb\dbg(1, "in-here"); | ||
// hb\e(hb\HB::$Q); | ||
usleep(800); | ||
iprofiler()->info("info", ['reason' => 'test:', 'p' => $param1]); | ||
usleep(900); | ||
if ($deep == 3) { | ||
static $cnt = 0; | ||
if (! $cnt++) | ||
iprofiler()->alert("alert",['reason' => 'test alert', 'p' => $param1]); | ||
} | ||
elseif ($deep == 4) | ||
iprofiler()->warn("warning",['reason' => 'test warning', 'p' => $param1]); | ||
else | ||
iprofiler()->info("some info",['rxx' => 'test', \hb\Str::random(3)]); | ||
if ($deep > 4) { | ||
$API_KEY = \hb\Str::random(6); | ||
iprofiler()->info("api-call", ["xxarams" => $param1], ['api' => $API_KEY]); | ||
return; | ||
} | ||
if ($deep > 3) | ||
iprofiler()->inHide("xx$deep", [\hb\Str::random(3) => \hb\Str::random()], ['tag' => $deep & 1 ? 'sql' : 'mongo', 'details' => '/dvp/vvv']); | ||
else | ||
iprofiler()->in("xx$deep", [\hb\Str::random(2) => \hb\Str::random(5)], ['tag' => 'sql', 'edit' => "/dvp/edit"]); | ||
usleep(900); | ||
$x = [1,2]; | ||
self::methodName($deep, $x, $deep+1); | ||
self::methodName($deep."x", $x, $deep+1); | ||
iprofiler()->out(); | ||
# <h1>H1sdfs</h1> | ||
#1/0; | ||
#C(str_repeat("unknonwn.node;", 22)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace app1\action; | ||
|
||
class Root extends \hb\Action { | ||
|
||
function index() { | ||
echo "hello world"; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
if (! defined("APP_DIR")) | ||
define("APP_DIR", __DIR__); | ||
define("PROJECT_DIR", __DIR__); | ||
include __DIR__."/vendor/hb2/src/homebase-bundle.inc.php"; // homebase project init | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/env p | ||
<?php | ||
|
||
# file develper play with | ||
v(C("A")); | ||
v(C("B")); | ||
v(C("tier")); | ||
v("--config", i('config')->_appConfig()); | ||
v("--config", i('config')->_projectConfig()); | ||
|
||
# v("--fw-config", i('config')->getFrameworkDefault()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/php | ||
<?php | ||
|
||
include __DIR__."/../init.php"; | ||
|
||
// project-specific init | ||
# iprofiler()->enable(true); // turn on profiler EVEN in cli mode ## same as "--profile" | ||
# iprofiler()->trace(); // echo all profiler calls (debug mode only) ## same as "--trace" | ||
# iprofiler()->trace('File', ['filename' => 'trace.log']); // save all profiler calls to file (debug mode only) | ||
echo i('cli')->red("red bold text", "bold"), "\n"; | ||
i('cli')->e("{red}{bold}%s{/}\n", "red bold text"); | ||
|
||
iprofiler()->in("a"); | ||
iprofiler()->in("b"); | ||
iprofiler()->in("b:1"); | ||
iprofiler()->out(); | ||
iprofiler()->in("b:2"); | ||
usleep(2000); | ||
iprofiler()->out(); | ||
iprofiler()->in("b:3"); | ||
i('cli')->box("Hello World"); | ||
iprofiler()->out(); | ||
iprofiler()->out(['x' => 1]); | ||
iprofiler()->out(); | ||
iprofiler()->in("cc"); | ||
iprofiler()->out(); | ||
|
||
# iprofiler()->debug(); |