<s> """<STR_LIT>""" <EOL> from __future__ import division <EOL> import os , sys <EOL> import time <EOL> import ev <EOL> from evennia . utils . idmapper import base as _idmapper <EOL> LOGFILE = "<STR_LIT>" <EOL> INTERVAL = <NUM_LIT:30> <EOL> class Memplot ( ev . Script ) : <EOL> """<STR_LIT>""" <EOL> def at_script_creation ( self ) : <EOL> "<STR_LIT>" <EOL> self . key = "<STR_LIT>" <EOL> self . desc = "<STR_LIT>" <EOL> self . start_delay = False <EOL> self . persistent = True <EOL> self . interval = INTERVAL <EOL> self . db . starttime = time . time ( ) <EOL> def at_repeat ( self ) : <EOL> "<STR_LIT>" <EOL> pid = os . getpid ( ) <EOL> rmem = float ( os . popen ( '<STR_LIT>' % ( pid , "<STR_LIT>" ) ) . read ( ) ) / <NUM_LIT> <EOL> vmem = float ( os . popen ( '<STR_LIT>' % ( pid , "<STR_LIT>" ) ) . read ( ) ) / <NUM_LIT> <EOL> total_num , cachedict = _idmapper . cache_size ( ) <EOL> t0 = ( time . time ( ) - self . db . starttime ) / <NUM_LIT> <EOL> with open ( LOGFILE , "<STR_LIT:a>" ) as f : <EOL> f . write ( "<STR_LIT>" % ( t0 , rmem , vmem , int ( total_num ) ) ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> from matplotlib import pyplot as pp <EOL> import numpy <EOL> data = numpy . genfromtxt ( "<STR_LIT>" + LOGFILE , delimiter = "<STR_LIT:U+002C>" ) <EOL> secs = data [ : , <NUM_LIT:0> ] <EOL> rmem = data [ : , <NUM_LIT:1> ] <EOL> vmem = data [ : , <NUM_LIT:2> ] <EOL> nobj = data [ : , <NUM_LIT:3> ] <EOL> fig = pp . figure ( ) <EOL> ax1 = fig . add_subplot ( <NUM_LIT> ) <EOL> ax1 . set_title ( "<STR_LIT>" ) <EOL> ax1 . set_xlabel ( "<STR_LIT>" ) <EOL> ax1 . set_ylabel ( "<STR_LIT>" ) <EOL> ax1 . plot ( secs , rmem , "<STR_LIT:r>" , label = "<STR_LIT>" , lw = <NUM_LIT:2> ) <EOL> ax1 . plot ( secs , vmem , "<STR_LIT:b>" , label = "<STR_LIT>" , lw = <NUM_LIT:2> ) <EOL> ax1 . legend ( loc = "<STR_LIT>" ) <EOL> ax2 = ax1 . twinx ( ) <EOL> ax2 . plot ( secs , nobj , "<STR_LIT>" , label = "<STR_LIT>" , lw = <NUM_LIT:2> ) <EOL> ax2 . set_ylabel ( "<STR_LIT>" ) <EOL> ax2 . legend ( loc = "<STR_LIT>" ) <EOL> ax2 . annotate ( "<STR_LIT>" , xy = ( <NUM_LIT:10> , <NUM_LIT> ) ) <EOL> ax2 . annotate ( "<STR_LIT>" , xy = ( <NUM_LIT> , <NUM_LIT> ) ) <EOL> pp . show ( ) </s>
