📄 test_memspeed.c
字号:
/*************************************************************************** memspeed.c - RTLinux kernel module for testing memory-speed ------------------- begin : 2002 authors : Linus Gasser emails : linus.gasser@epfl.ch ***************************************************************************//*************************************************************************** Changes ------- date - name - description2002-10-02 - ineiti - begin **************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************//** * Debugging priorities * * LVL 0 : Error messages only * LVL 1 : Important status messages * LVL 2 : Not too much traffic * LVL 3 : A bit more detailed * LVL 4 : S P A M - all we can do * * This way you can increase or decreas the level of debugging * messages depending on what you're doing. */#define DBG_LVL 4#include "system.h"#include "debugging.h"#include "memory.h"#include "connection.h"#include "sdb.h"void *test_it( void *arg ) { void *data; int i, tb, te; tb = get_time_usec(); for ( i=0; i<1000000; i++ ) { data = swr_malloc( 8 ); swr_free( data ); } te = get_time_usec(); PR_DBG( 0, "Total time for 1e6 mallocs/free: %ius\n", te - tb ); return 0;}/** * This function is called upon loading of the module */pthread_t thread;int swr_memspeed_init(void) { if ( pthread_create( &thread, 0, test_it, 0) < 0 ) { PR_DBG( 0, "Failed to create test_it thread\n"); return 1; } PR_DBG( 0, "memspeed initialised\n" ); return 0;}/** * This function is called when the module is unloaded. */void swr_memspeed_cleanup(void) { PR_DBG( 0, "memspeed cleaned up\n" ); pthread_join( thread, NULL ); pthread_cancel( thread ); swr_memory_show();}/** * Kernel macros which define the initialization and finalization * function. */module_init(swr_memspeed_init);module_exit(swr_memspeed_cleanup);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -