Browse Source
Apply SD on original document from CLI command. Add performance analyzer for CLI ran operations.
master
Apply SD on original document from CLI command. Add performance analyzer for CLI ran operations.
master
Orzu Ionut
3 years ago
11 changed files with 347 additions and 53 deletions
-
132app/Console/Commands/RunSearchDisplace.php
-
36app/Events/SDAppliedOnMarkdownDocument.php
-
36app/Events/SDAppliedOnOriginalDocument.php
-
45app/Listeners/AnalyzeOperationPerformance.php
-
11app/Providers/EventServiceProvider.php
-
24app/SearchDisplace/Ingest/HandleReceivedDocument.php
-
20app/SearchDisplace/Ingest/SendDocument.php
-
4app/SearchDisplace/SearchAndDisplace.php
-
9app/SearchDisplace/SearchAndDisplaceFromFiles.php
-
53app/SearchDisplace/SearchAndDisplaceOriginalDocument.php
-
30demo-cli/README.md
@ -0,0 +1,36 @@ |
|||
<?php |
|||
|
|||
namespace App\Events; |
|||
|
|||
use Illuminate\Broadcasting\Channel; |
|||
use Illuminate\Broadcasting\InteractsWithSockets; |
|||
use Illuminate\Broadcasting\PresenceChannel; |
|||
use Illuminate\Broadcasting\PrivateChannel; |
|||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; |
|||
use Illuminate\Foundation\Events\Dispatchable; |
|||
use Illuminate\Queue\SerializesModels; |
|||
|
|||
class SDAppliedOnMarkdownDocument |
|||
{ |
|||
use Dispatchable, InteractsWithSockets, SerializesModels; |
|||
|
|||
/** |
|||
* Create a new event instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
//
|
|||
} |
|||
|
|||
/** |
|||
* Get the channels the event should broadcast on. |
|||
* |
|||
* @return \Illuminate\Broadcasting\Channel|array |
|||
*/ |
|||
public function broadcastOn() |
|||
{ |
|||
return new PrivateChannel('channel-name'); |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
<?php |
|||
|
|||
namespace App\Events; |
|||
|
|||
use Illuminate\Broadcasting\Channel; |
|||
use Illuminate\Broadcasting\InteractsWithSockets; |
|||
use Illuminate\Broadcasting\PresenceChannel; |
|||
use Illuminate\Broadcasting\PrivateChannel; |
|||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; |
|||
use Illuminate\Foundation\Events\Dispatchable; |
|||
use Illuminate\Queue\SerializesModels; |
|||
|
|||
class SDAppliedOnOriginalDocument |
|||
{ |
|||
use Dispatchable, InteractsWithSockets, SerializesModels; |
|||
|
|||
/** |
|||
* Create a new event instance. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
//
|
|||
} |
|||
|
|||
/** |
|||
* Get the channels the event should broadcast on. |
|||
* |
|||
* @return \Illuminate\Broadcasting\Channel|array |
|||
*/ |
|||
public function broadcastOn() |
|||
{ |
|||
return new PrivateChannel('channel-name'); |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
<?php |
|||
|
|||
namespace App\Listeners; |
|||
|
|||
use Illuminate\Contracts\Queue\ShouldQueue; |
|||
use Illuminate\Queue\InteractsWithQueue; |
|||
use Illuminate\Support\Carbon; |
|||
use Illuminate\Support\Facades\Redis; |
|||
|
|||
class AnalyzeOperationPerformance |
|||
{ |
|||
/** |
|||
* Create the event listener. |
|||
* |
|||
* @return void |
|||
*/ |
|||
public function __construct() |
|||
{ |
|||
//
|
|||
} |
|||
|
|||
/** |
|||
* Handle the event. |
|||
* |
|||
* @param object $event |
|||
* @return void |
|||
*/ |
|||
public function handle($event) |
|||
{ |
|||
$redis = Redis::connection(); |
|||
|
|||
$directoryPath = $redis->get('analyze_performance_path'); |
|||
$startedAt = $redis->get('analyze_performance_time'); |
|||
|
|||
if ( ! $directoryPath || ! $startedAt) { |
|||
return; |
|||
} |
|||
|
|||
$endedAt = Carbon::now()->format('U'); |
|||
|
|||
$data = 'Time elapsed in seconds: ' . ($endedAt - $startedAt) . "\n"; |
|||
|
|||
file_put_contents($directoryPath . '/sd_analyze_performance.txt', $data); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue