Skip to content

Instantly share code, notes, and snippets.

@v-lopez
Last active May 16, 2018 16:09
Show Gist options
  • Save v-lopez/94234335d2fbab1e302821fa39c7b254 to your computer and use it in GitHub Desktop.
Save v-lopez/94234335d2fbab1e302821fa39c7b254 to your computer and use it in GitHub Desktop.
rospy_mem_test.py
#!/usr/bin/env python
from __future__ import division
import os
import psutil
previous_mem=0
def print_memory(label=""):
global previous_mem
process = psutil.Process(os.getpid())
try:
new_mem=process.memory_info().rss / 1024
except:
# This is the syntax in the indigo version
new_mem=process.get_memory_info().rss / 1024
difference=new_mem - previous_mem
previous_mem = new_mem
print("{}: {}KB (difference {}KB)".format(label, new_mem, difference))
print_memory()
# from std_msgs.msg import Header
# print_memory("Header")
import sys
print_memory("sys")
python3 = True if sys.hexversion > 0x03000000 else False
print_memory("python3")
#from __future__ import division
# print_memory()
import numbers
print_memory("numbers")
import sys
print_memory("sys")
import warnings
print_memory("warnings")
from genpy.rostime import Time
print_memory("rostime")
import rospy
print_memory("rospy")
# from genpy.message import Message, SerializationError, DeserializationError, MessageException, struct_I
# print_memory("message")
# import genpy
# print_memory("genpy")
# import struct
# print_memory("Struct")
# from std_msgs.msg._Bool import *
# print_memory("Bool")
# from std_msgs.msg._Byte import *
# print_memory()
# # from std_msgs.msg._ByteMultiArray import *
# # print_memory()
# # from std_msgs.msg._Char import *
# # print_memory()
# # from std_msgs.msg._ColorRGBA import *
# # print_memory()
# # from std_msgs.msg._Duration import *
# # print_memory()
# # from std_msgs.msg._Empty import *
# # print_memory()
# # from std_msgs.msg._Float32 import *
# # print_memory()
# # from std_msgs.msg._Float32MultiArray import *
# # print_memory()
# # from std_msgs.msg._Float64 import *
# # print_memory()
# # from std_msgs.msg._Float64MultiArray import *
# # print_memory()
# # from std_msgs.msg._Header import *
# # print_memory()
# # from std_msgs.msg._Int16 import *
# # print_memory()
# # from std_msgs.msg._Int16MultiArray import *
# # print_memory()
# # from std_msgs.msg._Int32 import *
# # print_memory()
# # from std_msgs.msg._Int32MultiArray import *
# # print_memory()
# # from std_msgs.msg._Int64 import *
# # print_memory()
# # from std_msgs.msg._Int64MultiArray import *
# # print_memory()
# # from std_msgs.msg._Int8 import *
# # print_memory()
# # from std_msgs.msg._Int8MultiArray import *
# # print_memory()
# # from std_msgs.msg._MultiArrayDimension import *
# # print_memory()
# # from std_msgs.msg._MultiArrayLayout import *
# # print_memory()
# # from std_msgs.msg._String import *
# # print_memory()
# # from std_msgs.msg._Time import *
# # print_memory()
# # from std_msgs.msg._UInt16 import *
# # print_memory()
# # from std_msgs.msg._UInt16MultiArray import *
# # print_memory()
# # from std_msgs.msg._UInt32 import *
# # print_memory()
# # from std_msgs.msg._UInt32MultiArray import *
# # print_memory()
# # from std_msgs.msg._UInt64 import *
# # print_memory()
# # from std_msgs.msg._UInt64MultiArray import *
# # print_memory()
# # from std_msgs.msg._UInt8 import *
# # print_memory()
# # from std_msgs.msg._UInt8MultiArray import *
# # print_memory()
# from rospy.client import spin, myargv, init_node, \
# get_published_topics, \
# wait_for_message, \
# get_master, \
# on_shutdown, \
# get_param, get_param_names, set_param, delete_param, has_param, search_param,\
# DEBUG, INFO, WARN, ERROR, FATAL
# print_memory()
# from rospy.timer import sleep, Rate, Timer
# print_memory()
# from rospy.core import is_shutdown, signal_shutdown, \
# get_node_uri, get_ros_root, \
# logdebug, logwarn, loginfo, logout, logerr, logfatal, \
# logdebug_throttle, logwarn_throttle, loginfo_throttle, logerr_throttle, logfatal_throttle, \
# parse_rosrpc_uri
# print_memory()
# from rospy.exceptions import *
# print_memory()
# from rospy.msg import AnyMsg
# print_memory()
# from rospy.msproxy import MasterProxy
# print_memory()
# from rospy.names import get_name, get_caller_id, get_namespace, resolve_name, remap_name
# print_memory()
# from rospy.rostime import Time, Duration, get_rostime, get_time
# print_memory()
# from rospy.service import ServiceException
# print_memory()
# # - use tcp ros implementation of services
# from rospy.impl.tcpros_service import Service, ServiceProxy, wait_for_service
# print_memory()
# from rospy.topics import Message, SubscribeListener, Publisher, Subscriber
# print_memory()
# import rospy
# print_memory()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment