benchmark_api.h

Go to the documentation of this file.
00001 /*
00002  * $Id: benchmark_api.h 944 2007-04-11 12:43:49Z bastian $
00003  *
00004  * Benchmarking module for Kamailio
00005  *
00006  * Copyright (C) 2007 Collax GmbH
00007  *                    (Bastian Friedrich <bastian.friedrich@collax.com>)
00008  * Copyright (C) 2007 Voice Sistem SRL
00009  *
00010  * This file is part of Kamailio, a free SIP server.
00011  *
00012  * Kamailio is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version
00016  *
00017  * Kamailio is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  */
00027 
00036 #ifndef BENCHMARK_API_H
00037 #define BENCHMARK_API_H
00038 
00039 #include "../../sr_module.h"
00040 
00041 typedef int (*bm_register_timer_f)(char *tname, int mode, unsigned int *id);
00042 typedef int (*bm_start_timer_f)(unsigned int id);
00043 typedef int (*bm_log_timer_f)(unsigned int id);
00044 
00045 struct bm_binds {
00046         bm_register_timer_f bm_register;
00047         bm_start_timer_f bm_start;
00048         bm_log_timer_f bm_log;
00049 };
00050 
00051 typedef int(*load_bm_f)(struct bm_binds *bmb);
00052 
00053 int load_bm(struct bm_binds *bmb);
00054 
00055 static inline int load_bm_api( struct bm_binds *bmb )
00056 {
00057         load_bm_f load_bm;
00058 
00059         /* import the benchmark auto-loading function */
00060         if ( !(load_bm=(load_bm_f)find_export("load_bm", 0, 0)))
00061         {
00062                 LM_ERR("can't import load_bm\n");
00063                 return -1;
00064         }
00065         /* let the auto-loading function load all benchmarking stuff */
00066         if (load_bm( bmb )==-1)
00067         {
00068                 LM_ERR("load_bm failed\n");
00069                 return -1;
00070         }
00071         
00072         return 0;
00073 }
00074 
00075 #endif /* BENCHMARK_API_H */