# # $Id: sprof.patch,v 1.2 1998/05/16 02:24:22 joi Exp $ # $Log: sprof.patch,v $ # Revision 1.2 1998/05/16 02:24:22 joi # Fixed missing pointer initialization. # # # Sprof Patch for TinyMUSH 2.2.3. # J. Ellis, joi.ellis@cdc.com, gyles19@nospam.visi.com 03/29/98 # # USE AT YOUR OWN RISK! # # This patch adds support for rudimentary profiling in the server log. # The following commands are added: # # @admin log=profile (enables profiler data in the log) # @set =profile (enables profiling of a specific object) # @set =profile (enables profiling of all a player's code) # # These may only be used by god. See the wizhelp additions at the end of # this patch file for further information. # *** ./src/config.h 1995/03/29 23:42:49 1.9 --- /usr/local/src/tinymush-2.2.3/src/config.h 1998/03/30 02:15:33 *************** *** 34,39 **** --- 34,45 ---- */ /* #define NO_LAG_CHECK */ + /* SPROF: + * Select whether or not you want to enable softcode profiling and the + * PROFILE flag. + */ + /* #define SPROF */ + /* PARANOID_EMIT: * Select whether or not you want to insist that @emit, @pemit and friends * require the player Affecting the target object. (Right now it is always diff -c ./src/cque.c /usr/local/src/tinymush-2.2.3/src/cque.c *** ./src/cque.c Sun Nov 17 08:57:47 1996 --- /usr/local/src/tinymush-2.2.3/src/cque.c Sun Mar 29 18:41:33 1998 *************** *** 15,20 **** --- 15,23 ---- #include "flags.h" #include "command.h" #include "alloc.h" + #ifdef SPROF + #include + #endif /* SPROF */ extern int FDECL(a_Queue, (dbref, int)); extern void FDECL(s_Queue, (dbref, int)); *************** *** 650,655 **** --- 653,664 ---- int count, i; char *command, *cp, *cmdsave, *logbuf, *log_cmdbuf; long begin_time, used_time; + #ifdef SPROF + clock_t sprof_start, sprof_end, sprof_used; + struct tms sprof_buffer; + struct tms *sprof; + int profile_thing; + #endif /* SPROF */ if ((mudconf.control_flags & CF_DEQUEUE) == 0) return 0; *************** *** 691,701 **** --- 700,722 ---- #ifndef NO_LAG_CHECK begin_time = time(NULL); #endif /* NO_LAG_CHECK */ + #ifdef SPROF + profile_thing = (Profile(player) + || Profile(Owner(player))); + if (profile_thing) + sprof_start = times(sprof); + #endif /* SPROF */ + log_cmdbuf = process_command(player, mudstate.qfirst->cause, 0, cp, mudstate.qfirst->env, mudstate.qfirst->nargs); + #ifdef SPROF + if (profile_thing) { + sprof_end = times(sprof); + } + #endif /* SPROF */ #ifndef NO_LAG_CHECK used_time = time(NULL) - begin_time; if (used_time >= mudconf.max_cmdsecs) { *************** *** 709,714 **** --- 730,749 ---- ENDLOG } #endif /* NO_LAG_CHECK */ + #ifdef SPROF + if (profile_thing) { + sprof_used = sprof_end - sprof_start; + STARTLOG(LOG_SPROF, "CMD", "PROF") + log_name_and_loc(player); + logbuf = alloc_lbuf("do_top.LOG.prof"); + sprintf(logbuf, " ticks %d (enactor #%d): ", sprof_used, mudstate.qfirst->cause); + log_text(logbuf); + free_lbuf(logbuf); + log_text(log_cmdbuf); + ENDLOG + } + + #endif /* SPROF */ mudstate.curr_cmd = (char *) ""; } } diff -c ./src/flags.c /usr/local/src/tinymush-2.2.3/src/flags.c *** ./src/flags.c Sun Nov 17 08:57:49 1996 --- /usr/local/src/tinymush-2.2.3/src/flags.c Sun Mar 29 17:32:12 1998 *************** *** 235,240 **** --- 235,244 ---- FLAG_EXT, 0, fh_any}, {"MYOPIC", MYOPIC, 'm', 0, 0, fh_any}, + #ifdef SPROF + {"PROFILE", PROFILE, 'o', + FLAG_EXT, CA_GOD, fh_god}, + #endif /* SPROF */ {"PUPPET", PUPPET, 'p', 0, 0, fh_hear_bit}, {"TERSE", TERSE, 'q', diff -c ./src/flags.h /usr/local/src/tinymush-2.2.3/src/flags.h *** ./src/flags.h Sun Nov 17 08:57:49 1996 --- /usr/local/src/tinymush-2.2.3/src/flags.h Sun Mar 29 17:32:12 1998 *************** *** 68,73 **** --- 68,76 ---- #define HAS_COMMANDS 0x00000400 /* Check it for $commands */ #define BOUNCE 0x00000800 /* Forward messages to contents */ #define HTML 0x00010000 /* Player supports HTML */ + #ifdef SPROF + #define PROFILE 0x00020000 /* Profile this object */ + #endif /* SPROF */ #define SUSPECT 0x10000000 /* Report some activities to wizards */ #define BUILDER 0x20000000 /* Player may build */ #define CONNECTED 0x40000000 /* Player is connected */ *************** *** 275,280 **** --- 278,286 ---- #define Going(x) ((Flags(x) & GOING) != 0) #define Monitor(x) ((Flags(x) & MONITOR) != 0) #define Myopic(x) ((Flags(x) & MYOPIC) != 0) + #ifdef SPROF + #define Profile(x) ((Flags2(x) & PROFILE) != 0) + #endif /* SPROF */ #define Puppet(x) ((Flags(x) & PUPPET) != 0) #define Chown_ok(x) ((Flags(x) & CHOWN_OK) != 0) #define Enter_ok(x) (((Flags(x) & ENTER_OK) != 0) && \ diff -c ./src/log.c /usr/local/src/tinymush-2.2.3/src/log.c *** ./src/log.c Sun Nov 17 08:57:49 1996 --- /usr/local/src/tinymush-2.2.3/src/log.c Sun Mar 29 17:32:11 1998 *************** *** 35,41 **** --- 35,46 ---- {(char *) "killing", 1, 0, LOG_KILLS}, {(char *) "logins", 1, 0, LOG_LOGIN}, {(char *) "network", 1, 0, LOG_NET}, + #ifdef SPROF + {(char *) "problems", 4, 0, LOG_PROBLEMS}, + {(char *) "profile", 4, 0, LOG_SPROF}, + #else /* SPROF */ {(char *) "problems", 1, 0, LOG_PROBLEMS}, + #endif /* SPROF */ {(char *) "security", 2, 0, LOG_SECURITY}, {(char *) "shouts", 2, 0, LOG_SHOUTS}, {(char *) "startup", 2, 0, LOG_STARTUP}, diff -c ./src/mudconf.h /usr/local/src/tinymush-2.2.3/src/mudconf.h *** ./src/mudconf.h Sun Nov 17 08:57:52 1996 --- /usr/local/src/tinymush-2.2.3/src/mudconf.h Sun Mar 29 17:43:19 1998 *************** *** 401,406 **** --- 402,410 ---- #define LOG_WIZARD 0x00002000 /* Log dangerous things */ #define LOG_ALLOCATE 0x00004000 /* Log alloc/free from buffer pools */ #define LOG_PROBLEMS 0x00008000 /* Log runtime problems */ + #ifdef SPROF + #define LOG_SPROF 0x01000000 /* Log profiling info */ + #endif #define LOG_ALWAYS 0x80000000 /* Always log it */ #define LOGOPT_FLAGS 0x01 /* Report flags on object */ *** ./text/wizhelp.txt Tue Apr 23 14:19:01 1996 --- /usr/local/src/tinymush-2.2.3/text/wizhelp.txt Sun Mar 29 19:05:30 1998 *************** *** 44,51 **** & flags Information is available on the following flags: ! INHERIT(i) MARKED(m) STARTUP(z) SUSPECT(u) ! WIZARD(W) & examine Command: examine[/] [] --- 44,51 ---- & flags Information is available on the following flags: ! INHERIT(i) MARKED(m) PROFILE(o) STARTUP(z) ! SUSPECT(u) WIZARD(W) & examine Command: examine[/] [] *************** *** 1546,1556 **** logins - Record connects to characters. network - Record new and broken net connections. problems - Record problems found with the database. security - Record security-related events. shouts - Record uses of the @wall command. startup - Record information about game startup. wizard - Record uses of dangerous commands like @toad. ! See also: log_options. & log_options Config parameter: log_options [!]