Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 import sys
00035 import rospkg
00036 
00037 rospack = rospkg.RosPack()
00038 base_path = rospack.get_path('rosconsole')
00039 
00040 f = open('%s/test/speed_test.cpp' % (base_path), 'w')
00041 
00042 f.write("// !!!!!!!!!!!!!!!!!!!!!!! This is a generated file, do not edit manually\n\n")
00043 
00044 f.write('/*\n')
00045 f.write(' * Copyright (c) 2008, Willow Garage, Inc.\n')
00046 f.write(' * All rights reserved.\n')
00047 f.write(' *\n')
00048 f.write(' * Redistribution and use in source and binary forms, with or without\n')
00049 f.write(' * modification, are permitted provided that the following conditions are met:\n')
00050 f.write(' *\n')
00051 f.write(' *     * Redistributions of source code must retain the above copyright\n')
00052 f.write(' *       notice, this list of conditions and the following disclaimer.\n')
00053 f.write(' *     * Redistributions in binary form must reproduce the above copyright\n')
00054 f.write(' *       notice, this list of conditions and the following disclaimer in the\n')
00055 f.write(' *       documentation and/or other materials provided with the distribution.\n')
00056 f.write(' *     * Neither the name of Willow Garage, Inc. nor the names of its\n')
00057 f.write(' *       contributors may be used to endorse or promote products derived from\n')
00058 f.write(' *       this software without specific prior written permission.\n')
00059 f.write(' *\n')
00060 f.write(' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\n')
00061 f.write(' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n')
00062 f.write(' * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n')
00063 f.write(' * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n')
00064 f.write(' * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n')
00065 f.write(' * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n')
00066 f.write(' * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n')
00067 f.write(' * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n')
00068 f.write(' * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n')
00069 f.write(' * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n')
00070 f.write(' * POSSIBILITY OF SUCH DAMAGE.\n')
00071 f.write(' */\n\n')
00072 
00073 f.write('#include "ros/console.h"\n')
00074 f.write('#include "log4cxx/appenderskeleton.h"\n')
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 f.write('class NullAppender : public log4cxx::AppenderSkeleton {\n')
00084 f.write('protected:\n')
00085 f.write('virtual void append(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool){printf("blah\\n");}\n')
00086 f.write('virtual void close() {}\n')
00087 f.write('virtual bool requiresLayout() const { return false; } };\n')
00088 
00089 f.write('int main(int argc, char** argv)\n{\n')
00090 f.write('ROSCONSOLE_AUTOINIT; \nlog4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->removeAllAppenders();\n')
00091 f.write('log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender(new NullAppender);\n')
00092 f.write('log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->setLevel(log4cxx::Level::getFatal());\n')
00093 f.write('for (int i = 0;i < %s; ++i)\n{\n' %(sys.argv[2]))
00094 
00095 for i in range(0,int(sys.argv[1])):
00096     
00097     
00098     
00099     
00100     
00101     f.write('ROS_INFO("test");')
00102     f.write('ROS_WARN("test");')
00103     f.write('ROS_ERROR("test");')
00104     f.write('ROS_DEBUG("test");')
00105     f.write('ROS_ERROR("test");')
00106 
00107 f.write('}\n')
00108 f.write('}\n')
00109