📄 perf.c
字号:
/* iksemel (XML parser for Jabber)** Copyright (C) 2000-2003 Gurer Ozen <madcat@e-kolay.net>** This code is free software; you can redistribute it and/or** modify it under the terms of GNU Lesser General Public License.*/#include <stdio.h>#include <stdlib.h>#include <string.h>#ifdef _WIN32#include <windows.h>#include <limits.h>#else#include <sys/time.h>#endif#include "iksemel.h"/* timing functions */#ifdef _WIN32static DWORD start_tv;voidt_reset (void){ start_tv = GetTickCount ();}unsigned longt_elapsed (void){ DWORD end_tv; end_tv = GetTickCount (); if (end_tv < start_tv) return UINT_MAX - (start_tv - end_tv - 1); else return end_tv - start_tv;}#elsestatic struct timeval start_tv;voidt_reset (void){ gettimeofday (&start_tv, NULL);}unsigned longt_elapsed (void){ unsigned long msec; struct timeval cur_tv; gettimeofday (&cur_tv, NULL); msec = (cur_tv.tv_sec * 1000) + (cur_tv.tv_usec / 1000); msec -= (start_tv.tv_sec * 1000) + (start_tv.tv_usec / 1000); return msec;}#endif/* memory functions */static void *m_malloc (size_t size){ void *ptr = malloc (size); printf ("MEM: malloc (%d) => %p\n", size, ptr); return ptr;}static voidm_free (void *ptr){ printf ("MEM: free (%p)\n", ptr);}voidm_trace (void){ iks_set_mem_funcs (m_malloc, m_free);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -