12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- class IndexAction extends Action {
-
-
- public function index( ){
- echo 'hello world';
- }
-
- public function create_route(){
- if( PHP_SAPI != 'cli' ){
- exit(PHP_SAPI);
- }
- echo '['.date('Y-m-d H:i:s').'] ———————————————————— starting create route ———————————————————— '.PHP_EOL;
- // 模拟添加数据,10万个标签,每个每秒产生1条数据
- $gps = M('gps_location_20190412','','mysql://dev:711e7D69f9d0c3f1@rm-bp13qpl023g02660t.mysql.rds.aliyuncs.com:3306/dev_fd_gps');
-
- $start_time = 1555050000; //2019-3-30 00:00:00
- while ( $start_time <= 1555050076) { //2019-3-30 23:59:59
-
- $deive_id = 100000000000001;
- for( $i=1; $i <= 100000; $i++ ){
- if( $i % 1200 == 1 ){
- $start_submit = microtime(true);
- $gps->startTrans();
- $data = array();
- }
- $data[] = array(
- 'DeviceId' => $deive_id + $i,
- 'DeviceTime' => $start_time,
- 'Longitude' => 120 + rand(200001,220562)/1000000,
- 'Latitude' => 30 + rand(260001,260818)/1000000,
- 'Speed' => rand(0, 40),
- 'Direction' => rand(1,8),
- 'Status' => rand(1,10),
- 'SatelliteCount' => rand(4,11),
- 'LBS' => 'abcdefgh'
- );
- if( $i % 1200 == 0 ){
- $gps->addAll($data);
- $gps->commit();
- $end_submit = microtime(true);
- var_dump('now ' . $i .' use ' . ($start_submit - $end_submit) .' memory_get_usage :' . memory_get_usage());
- }
- }
- usleep(1000);
- $start_time ++;
- }
- echo '['.date('Y-m-d H:i:s').'] ———————————————————— create route finished ———————————————————— '.PHP_EOL;
-
- }
- }
|