mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Perf: Improve fast find for pithy print
This commit is contained in:
parent
3a7c742f07
commit
adfca6069c
2 changed files with 10 additions and 2 deletions
|
@ -171,6 +171,7 @@ static SrsStageManager* _srs_stages = new SrsStageManager();
|
|||
SrsPithyPrint::SrsPithyPrint(int _stage_id)
|
||||
{
|
||||
stage_id = _stage_id;
|
||||
cache_ = NULL;
|
||||
client_id = enter_stage();
|
||||
previous_tick = srs_get_system_time();
|
||||
_age = 0;
|
||||
|
@ -308,7 +309,10 @@ void SrsPithyPrint::leave_stage()
|
|||
|
||||
void SrsPithyPrint::elapse()
|
||||
{
|
||||
SrsStageInfo* stage = _srs_stages->fetch_or_create(stage_id);
|
||||
SrsStageInfo* stage = cache_;
|
||||
if (!stage) {
|
||||
stage = cache_ = _srs_stages->fetch_or_create(stage_id);
|
||||
}
|
||||
srs_assert(stage != NULL);
|
||||
|
||||
srs_utime_t diff = srs_get_system_time() - previous_tick;
|
||||
|
@ -321,7 +325,10 @@ void SrsPithyPrint::elapse()
|
|||
|
||||
bool SrsPithyPrint::can_print()
|
||||
{
|
||||
SrsStageInfo* stage = _srs_stages->fetch_or_create(stage_id);
|
||||
SrsStageInfo* stage = cache_;
|
||||
if (!stage) {
|
||||
stage = cache_ = _srs_stages->fetch_or_create(stage_id);
|
||||
}
|
||||
srs_assert(stage != NULL);
|
||||
|
||||
return stage->can_print();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue