generate_speed_test.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 # Software License Agreement (BSD License)
00003 #
00004 # Copyright (c) 2008, Willow Garage, Inc.
00005 # All rights reserved.
00006 #
00007 # Redistribution and use in source and binary forms, with or without
00008 # modification, are permitted provided that the following conditions
00009 # are met:
00010 #
00011 #  * Redistributions of source code must retain the above copyright
00012 #    notice, this list of conditions and the following disclaimer.
00013 #  * Redistributions in binary form must reproduce the above
00014 #    copyright notice, this list of conditions and the following
00015 #    disclaimer in the documentation and/or other materials provided
00016 #    with the distribution.
00017 #  * Neither the name of Willow Garage, Inc. nor the names of its
00018 #    contributors may be used to endorse or promote products derived
00019 #    from this software without specific prior written permission.
00020 #
00021 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 # POSSIBILITY OF SUCH DAMAGE.
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 #for i in range(0,int(sys.argv[1])):
00077 #    f.write('void info%s(int i) { ROS_INFO("Info%s: %%d", i); }\n' %(i,i))
00078 #    f.write('void warn%s(int i) { ROS_WARN("Warn%s: %%d", i); }\n' %(i,i))
00079 #    f.write('void error%s(int i) { ROS_ERROR("Error%s: %%d", i); }\n' %(i,i))
00080 #    f.write('void debug%s(int i) { ROS_DEBUG("Debug%s: %%d", i); }\n' %(i,i))
00081 #    f.write('void errorr%s(int i) { ROS_ERROR("Error2%s: %%d", i); }\n' %(i,i))
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     #f.write('info%s(i);\n' %(i))
00097     #f.write('warn%s(i);\n' %(i))
00098     #f.write('error%s(i);\n' %(i))
00099     #f.write('debug%s(i);\n' %(i))
00100     #f.write('errorr%s(i);\n' %(i))
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 


rosconsole
Author(s): Josh Faust
autogenerated on Mon Oct 6 2014 11:46:34