evennia.server.profiling package¶
Submodules¶
evennia.server.profiling.dummyrunner module¶
Dummy client runner
This module implements a stand-alone launcher for stress-testing an Evennia game. It will launch any number of fake clients. These clients will log into the server and start doing random operations. Customizing and weighing these operations differently depends on which type of game is tested. The module contains a testing module for plain Evennia.
Please note that you shouldn’t run this on a production server! Launch the program without any arguments or options to see a full step-by-step setup help.
Basically (for testing default Evennia):
Use an empty/testing database.
set PERMISSION_ACCOUNT_DEFAULT = “Builder”
start server, eventually with profiling active
launch this client runner
If you want to customize the runner’s client actions (because you changed the cmdset or needs to better match your use cases or add more actions), you can change which actions by adding a path to
DUMMYRUNNER_ACTIONS_MODULE = <path.to.your.module>
in your settings. See utils.dummyrunner_actions.py for instructions on how to define this module.
-
class
evennia.server.profiling.dummyrunner.DummyClient[source]¶ Bases:
twisted.conch.telnet.StatefulTelnetProtocolHandles connection to a running Evennia server, mimicking a real account by sending commands on a timer.
-
connectionLost(reason)[source]¶ Called when loosing the connection.
- Parameters
reason (str) – Reason for loosing connection.
-
counter()[source]¶ Produces a unique id, also between clients.
- Returns
A unique counter.
- Return type
counter (int)
-
-
class
evennia.server.profiling.dummyrunner.DummyFactory(actions)[source]¶ Bases:
twisted.internet.protocol.ClientFactory-
protocol¶ alias of
DummyClient
-
-
evennia.server.profiling.dummyrunner.gidcounter()[source]¶ Makes globally unique ids.
- Returns
count (int); A globally unique counter.
-
evennia.server.profiling.dummyrunner.idcounter()[source]¶ Makes unique ids.
- Returns
A globally unique counter.
- Return type
count (int)
evennia.server.profiling.dummyrunner_settings module¶
Settings and actions for the dummyrunner
This module defines dummyrunner settings and sets up the actions available to dummy accounts.
The settings are global variables:
TIMESTEP - time in seconds between each ‘tick’ CHANCE_OF_ACTION - chance 0-1 of action happening CHANCE_OF_LOGIN - chance 0-1 of login happening TELNET_PORT - port to use, defaults to settings.TELNET_PORT ACTIONS - see below
ACTIONS is a tuple
(login_func, logout_func, (0.3, func1), (0.1, func2) … )
where the first entry is the function to call on first connect, with a chance of occurring given by CHANCE_OF_LOGIN. This function is usually responsible for logging in the account. The second entry is always called when the dummyrunner disconnects from the server and should thus issue a logout command. The other entries are tuples (chance, func). They are picked randomly, their commonality based on the cumulative chance given (the chance is normalized between all options so if will still work also if the given chances don’t add up to 1). Since each function can return a list of game-command strings, each function may result in multiple operations.
An action-function is called with a “client” argument which is a reference to the dummy client currently performing the action. It returns a string or a list of command strings to execute. Use the client object for optionally saving data between actions.
- The client object has the following relevant properties and methods:
- key - an optional client key. This is only used for dummyrunner output.
Default is “Dummy-<cid>”
cid - client id gid - globally unique id, hashed with time stamp istep - the current step exits - an empty list. Can be used to store exit names objs - an empty list. Can be used to store object names counter() - returns a unique increasing id, hashed with time stamp
to make it unique also between dummyrunner instances.
The return should either be a single command string or a tuple of command strings. This list of commands will always be executed every TIMESTEP with a chance given by CHANCE_OF_ACTION by in the order given (no randomness) and allows for setting up a more complex chain of commands (such as creating an account and logging in).
creates example button, storing name on client
-
evennia.server.profiling.dummyrunner_settings.c_creates_obj(client)[source]¶ creates normal objects, storing their name on client
-
evennia.server.profiling.dummyrunner_settings.c_digs(client)[source]¶ digs a new room, storing exit names on client
-
evennia.server.profiling.dummyrunner_settings.c_login_nodig(client)[source]¶ logins, don’t dig its own room
-
evennia.server.profiling.dummyrunner_settings.c_moves(client)[source]¶ moves to a previously created room, using the stored exits
-
evennia.server.profiling.dummyrunner_settings.c_moves_n(client)[source]¶ move through north exit if available
-
evennia.server.profiling.dummyrunner_settings.c_moves_s(client)[source]¶ move through south exit if available
socializechats on channel
evennia.server.profiling.memplot module¶
Script that saves memory and idmapper data over time.
Data will be saved to game/logs/memoryusage.log. Note that the script will append to this file if it already exists.
Call this module directly to plot the log (requires matplotlib and numpy).
-
class
evennia.server.profiling.memplot.Memplot(*args, **kwargs)[source]¶ Bases:
evennia.scripts.scripts.DefaultScriptDescribes a memory plotting action.
-
exception
DoesNotExist¶ Bases:
evennia.scripts.scripts.DoesNotExist
-
exception
MultipleObjectsReturned¶ Bases:
evennia.scripts.scripts.MultipleObjectsReturned
-
_meta= <Options for Memplot>¶
-
path= 'evennia.server.profiling.memplot.Memplot'¶
-
typename= 'Memplot'¶
-
exception
evennia.server.profiling.settings_mixin module¶
Dummyrunner mixin. Add this at the end of the settings file before running dummyrunner, like this:
from evennia.server.profiling.settings_mixin import *
Note that these mixin-settings are not suitable for production servers!
evennia.server.profiling.test_queries module¶
This is a little routine for viewing the sql queries that are executed by a given query as well as count them for optimization testing.
evennia.server.profiling.tests module¶
evennia.server.profiling.timetrace module¶
Trace a message through the messaging system
-
evennia.server.profiling.timetrace.timetrace(message, idstring, tracemessage='TEST_MESSAGE', final=False)[source]¶ Trace a message with time stamps.
- Parameters
message (str) – The actual message coming through
idstring (str) – An identifier string specifying where this trace is happening.
tracemessage (str) – The start of the message to tag. This message will get attached time stamp.
final (bool) – This is the final leg in the path - include total time in message