casadatos / dashboard
该包的最新版本(v1.0.0)没有可用的许可证信息。
v1.0.0
2017-03-11 16:57 UTC
Requires (Dev)
- phpunit/phpunit: 4.2.*
This package is auto-updated.
Last update: 2024-09-25 11:08:32 UTC
README
创建仪表板组件,让您知道代码是否运行顺畅。
/* Need it on dev only? No problem! */ if ($isDev) $this->dashboard = new ConsoleDashboard(); else $this->dashboard = new NullDashboard(); /* adding gauges */ $this->dashboard ->add('houses', new ValueGauge($length=6)) ->add('progress', new ProgressBarGauge($maxHauses=18000, $length=30,null,0)) ->add('json size', new ByteGauge($length=12)) ->add('loop memory', new DeltaMemoryGauge()) ->add('loop time', new TimeGauge()); /* some gauges are fed automatically with data some not */ $this->dashboard ->init(); // starts timers and zeroes stuff while ($working) { /* some loop in your code which you'd like to know how it performs its tasks */ // ... some tasks here $this->dashboard ->update('progress', count($this->housesArr)) ->update('houses', count($this->housesArr)) ->update('json size', $size); $this->refresh(); /* So far it refreshes on each loop iteration. Any idea how to control that? Let me know. Thought of making possible to be refreshed on some events and on specific time intervals like (X times per sec./ minute or whatever). So far you can only do it manually in your code. */ } /* ... and finally let's close */ $this->dashboard->summarize();
前面的代码在实时(工作过程中)产生以下仪表板。
+------+------------------------------+------------+------------+------------+
|houses| progress | json size |loop memory | loop time |
+------+------------------------------+------------+------------+------------+
| 18489|######################### 100%| 5381.73KB| 7.29MB| 0h 00m 54s|
+------+------------------------------+------------+------------+------------+