generate_speed_test.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 # Software License Agreement (BSD License)
3 #
4 # Copyright (c) 2008, Willow Garage, Inc.
5 # All rights reserved.
6 #
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
10 #
11 # * Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # * Redistributions in binary form must reproduce the above
14 # copyright notice, this list of conditions and the following
15 # disclaimer in the documentation and/or other materials provided
16 # with the distribution.
17 # * Neither the name of Willow Garage, Inc. nor the names of its
18 # contributors may be used to endorse or promote products derived
19 # from this software without specific prior written permission.
20 #
21 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 # POSSIBILITY OF SUCH DAMAGE.
33 
34 import os
35 import sys
36 
37 f = open('%s/../test/speed_test.cpp' % (os.path.dirname(__file__)), 'w')
38 
39 f.write("// !!!!!!!!!!!!!!!!!!!!!!! This is a generated file, do not edit manually\n\n")
40 
41 f.write('/*\n')
42 f.write(' * Copyright (c) 2008, Willow Garage, Inc.\n')
43 f.write(' * All rights reserved.\n')
44 f.write(' *\n')
45 f.write(' * Redistribution and use in source and binary forms, with or without\n')
46 f.write(' * modification, are permitted provided that the following conditions are met:\n')
47 f.write(' *\n')
48 f.write(' * * Redistributions of source code must retain the above copyright\n')
49 f.write(' * notice, this list of conditions and the following disclaimer.\n')
50 f.write(' * * Redistributions in binary form must reproduce the above copyright\n')
51 f.write(' * notice, this list of conditions and the following disclaimer in the\n')
52 f.write(' * documentation and/or other materials provided with the distribution.\n')
53 f.write(' * * Neither the name of Willow Garage, Inc. nor the names of its\n')
54 f.write(' * contributors may be used to endorse or promote products derived from\n')
55 f.write(' * this software without specific prior written permission.\n')
56 f.write(' *\n')
57 f.write(' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\n')
58 f.write(' * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n')
59 f.write(' * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n')
60 f.write(' * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n')
61 f.write(' * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n')
62 f.write(' * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n')
63 f.write(' * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n')
64 f.write(' * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n')
65 f.write(' * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n')
66 f.write(' * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n')
67 f.write(' * POSSIBILITY OF SUCH DAMAGE.\n')
68 f.write(' */\n\n')
69 
70 f.write('#include "ros/console.h"\n')
71 f.write('#include "log4cxx/appenderskeleton.h"\n')
72 
73 #for i in range(0,int(sys.argv[1])):
74 # f.write('void info%s(int i) { ROS_INFO("Info%s: %%d", i); }\n' %(i,i))
75 # f.write('void warn%s(int i) { ROS_WARN("Warn%s: %%d", i); }\n' %(i,i))
76 # f.write('void error%s(int i) { ROS_ERROR("Error%s: %%d", i); }\n' %(i,i))
77 # f.write('void debug%s(int i) { ROS_DEBUG("Debug%s: %%d", i); }\n' %(i,i))
78 # f.write('void errorr%s(int i) { ROS_ERROR("Error2%s: %%d", i); }\n' %(i,i))
79 
80 f.write('class NullAppender : public log4cxx::AppenderSkeleton {\n')
81 f.write('protected:\n')
82 f.write('virtual void append(const log4cxx::spi::LoggingEventPtr& event, log4cxx::helpers::Pool& pool){printf("blah\\n");}\n')
83 f.write('virtual void close() {}\n')
84 f.write('virtual bool requiresLayout() const { return false; } };\n')
85 
86 f.write('int main(int argc, char** argv)\n{\n')
87 f.write('ROSCONSOLE_AUTOINIT; \nlog4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME)->removeAllAppenders();\n')
88 f.write('log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->addAppender(new NullAppender);\n')
89 f.write('log4cxx::Logger::getLogger(ROSCONSOLE_DEFAULT_NAME)->setLevel(log4cxx::Level::getFatal());\n')
90 f.write('for (int i = 0;i < %s; ++i)\n{\n' %(sys.argv[2]))
91 
92 for i in range(0,int(sys.argv[1])):
93  #f.write('info%s(i);\n' %(i))
94  #f.write('warn%s(i);\n' %(i))
95  #f.write('error%s(i);\n' %(i))
96  #f.write('debug%s(i);\n' %(i))
97  #f.write('errorr%s(i);\n' %(i))
98  f.write('ROS_INFO("test");')
99  f.write('ROS_WARN("test");')
100  f.write('ROS_ERROR("test");')
101  f.write('ROS_DEBUG("test");')
102  f.write('ROS_ERROR("test");')
103 
104 f.write('}\n')
105 f.write('}\n')
106 


rosconsole
Author(s): Josh Faust
autogenerated on Sun Feb 3 2019 03:29:44