提交 8f4bbe2a 编写于 作者: Z Zhang Rui

ijksdl: introduce SDL_Profiler

上级 577a50ef
......@@ -28,6 +28,7 @@
#include "ff_fferror.h"
#include "ff_ffpipeline.h"
#include "ff_ffpipenode.h"
#include "ff_ffplay_debug.h"
#include "ijkmeta.h"
// FIXME: 9 work around NDKr8e or gcc4.7 bug
......@@ -43,17 +44,6 @@
#define printf(...) ALOGD(__VA_ARGS__)
#endif
#define FFP_XPS_PERIOD (3)
// #define FFP_SHOW_FPS
// #define FFP_SHOW_VDPS
// #define FFP_SHOW_AUDIO_DELAY
// #define FFP_SHOW_DEMUX_CACHE
// #define FFP_SHOW_BUF_POS
// #define FFP_SHOW_PKT_RECYCLE
// #define FFP_NOTIFY_BUF_TIME
// #define FFP_NOTIFY_BUF_BYTES
#define FFP_IO_STAT_STEP (50 * 1024)
#ifdef FFP_SHOW_VDPS
......
/*
* ff_ffplaye_debug.h
*
* Copyright (c) 2015 Zhang Rui <bbcallen@gmail.com>
*
* This file is part of ijkPlayer.
*
* ijkPlayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* ijkPlayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with ijkPlayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FFPLAY__FF_FFPLAY_DEBUG_H
#define FFPLAY__FF_FFPLAY_DEBUG_H
#define FFP_XPS_PERIOD (3)
// #define FFP_SHOW_FPS
// #define FFP_SHOW_VDPS
// #define FFP_SHOW_AUDIO_DELAY
// #define FFP_SHOW_DEMUX_CACHE
// #define FFP_SHOW_BUF_POS
// #define FFP_SHOW_PKT_RECYCLE
// #define FFP_NOTIFY_BUF_TIME
// #define FFP_NOTIFY_BUF_BYTES
#endif
......@@ -23,6 +23,7 @@
#include "ijksdl_timer.h"
#include <unistd.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
......@@ -76,3 +77,38 @@ Uint64 SDL_GetTickHR(void)
#endif
return (clock);
}
void SDL_ProfilerReset(SDL_Profiler* profiler, int max_sample)
{
memset(profiler, 0, sizeof(SDL_Profiler));
if (max_sample < 0)
profiler->max_sample = 3;
else
profiler->max_sample = max_sample;
}
void SDL_ProfilerBegin(SDL_Profiler* profiler)
{
profiler->begin_time = SDL_GetTickHR();
}
int64_t SDL_ProfilerEnd(SDL_Profiler* profiler)
{
int64_t delta = SDL_GetTickHR();
if (profiler->max_sample > 0) {
profiler->total_elapsed += delta;
profiler->total_counter += 1;
if (profiler->total_counter > profiler->max_sample) {
profiler->total_elapsed -= profiler->average_elapsed;
profiler->total_counter -= 1;
}
if (profiler->total_counter > 0) {
profiler->average_elapsed = profiler->total_elapsed / profiler->total_counter;
}
}
return delta;
}
......@@ -30,4 +30,18 @@ void SDL_Delay(Uint32 ms);
Uint64 SDL_GetTickHR(void);
typedef struct SDL_Profiler {
int64_t total_elapsed;
int total_counter;
int64_t average_elapsed;
int64_t begin_time;
int max_sample;
} SDL_Profiler;
void SDL_ProfilerReset(SDL_Profiler* profiler, int max_sample);
void SDL_ProfilerBegin(SDL_Profiler* profiler);
int64_t SDL_ProfilerEnd(SDL_Profiler* profiler);
#endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册