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


rosconsole
Author(s): Josh Faust
autogenerated on Tue Mar 7 2017 04:00:48