profiler.h (2849B)
1/** 2 * FreeRDP: A Remote Desktop Protocol Implementation 3 * Profiler Utils 4 * 5 * Copyright 2011 Stephen Erisman 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20#ifndef FREERDP_UTILS_PROFILER_H 21#define FREERDP_UTILS_PROFILER_H 22 23#include <freerdp/api.h> 24#include <freerdp/utils/stopwatch.h> 25 26typedef struct _PROFILER PROFILER; 27 28#ifdef __cplusplus 29extern "C" 30{ 31#endif 32 33 FREERDP_API PROFILER* profiler_create(const char* name); 34 FREERDP_API void profiler_free(PROFILER* profiler); 35 36 FREERDP_API void profiler_enter(PROFILER* profiler); 37 FREERDP_API void profiler_exit(PROFILER* profiler); 38 39 FREERDP_API void profiler_print_header(void); 40 FREERDP_API void profiler_print(PROFILER* profiler); 41 FREERDP_API void profiler_print_footer(void); 42 43#ifdef __cplusplus 44} 45#endif 46 47#ifdef WITH_PROFILER 48#define PROFILER_RENAME(prof, name) \ 49 do \ 50 { \ 51 profiler_free(prof); \ 52 prof = profiler_create(name); \ 53 } while (0) 54#define PROFILER_DEFINE(prof) PROFILER* prof; 55#define PROFILER_CREATE(prof, name) prof = profiler_create(name); 56#define PROFILER_FREE(prof) profiler_free(prof); 57#define PROFILER_ENTER(prof) profiler_enter(prof); 58#define PROFILER_EXIT(prof) profiler_exit(prof); 59#define PROFILER_PRINT_HEADER profiler_print_header(); 60#define PROFILER_PRINT(prof) profiler_print(prof); 61#define PROFILER_PRINT_FOOTER profiler_print_footer(); 62#else 63#define PROFILER_RENAME(prof, name) \ 64 do \ 65 { \ 66 } while (0) 67 68#define PROFILER_DEFINE(prof) 69#define PROFILER_CREATE(prof, name) \ 70 do \ 71 { \ 72 } while (0); 73#define PROFILER_FREE(prof) \ 74 do \ 75 { \ 76 } while (0); 77#define PROFILER_ENTER(prof) \ 78 do \ 79 { \ 80 } while (0); 81#define PROFILER_EXIT(prof) \ 82 do \ 83 { \ 84 } while (0); 85#define PROFILER_PRINT_HEADER \ 86 do \ 87 { \ 88 } while (0); 89#define PROFILER_PRINT(prof) \ 90 do \ 91 { \ 92 } while (0); 93#define PROFILER_PRINT_FOOTER \ 94 do \ 95 { \ 96 } while (0); 97#endif 98 99#endif /* FREERDP_UTILS_PROFILER_H */