Add profiling. Also some trivial optimisations to skip memcpying.

This commit is contained in:
Nicholas Marriott 2007-10-03 00:13:46 +00:00
parent a6d3594d39
commit ef91aac688
3 changed files with 28 additions and 7 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.9 2007-10-01 14:53:29 nicm Exp $ # $Id: Makefile,v 1.10 2007-10-03 00:13:46 nicm Exp $
.SUFFIXES: .c .o .y .h .SUFFIXES: .c .o .y .h
.PHONY: clean .PHONY: clean
@ -25,6 +25,11 @@ YACC= yacc -d
CC= cc CC= cc
INCDIRS+= -I. -I- -I/usr/local/include INCDIRS+= -I. -I- -I/usr/local/include
CFLAGS+= -DBUILD="\"$(VERSION) ($(DATE))\"" -DMETA="'${META}'" CFLAGS+= -DBUILD="\"$(VERSION) ($(DATE))\"" -DMETA="'${META}'"
.ifdef PROFILE
# Don't use ccache
CC= /usr/bin/gcc
CFLAGS+= -pg -DPROFILE -O0
.endif
.ifdef DEBUG .ifdef DEBUG
CFLAGS+= -g -ggdb -DDEBUG CFLAGS+= -g -ggdb -DDEBUG
LDFLAGS+= -Wl,-E LDFLAGS+= -Wl,-E
@ -40,6 +45,9 @@ INSTALLBIN= install -g bin -o root -m 555
INSTALLMAN= install -g bin -o root -m 444 INSTALLMAN= install -g bin -o root -m 444
LDFLAGS+= -L/usr/local/lib LDFLAGS+= -L/usr/local/lib
.ifdef PROFILE
LDFLAGS+= -pg
.endif
LIBS+= -lutil -lncurses LIBS+= -lutil -lncurses
OBJS= ${SRCS:S/.c/.o/:S/.y/.o/} OBJS= ${SRCS:S/.c/.o/:S/.y/.o/}

8
TODO
View File

@ -10,7 +10,6 @@
- scrollback - scrollback
- server doesn't handle SIGTERM anymore... - server doesn't handle SIGTERM anymore...
- copy/paste - copy/paste
- cleanup/redesign IPC
- the whole input/screen/local thing sucks a bit, reorganise/redesign it - the whole input/screen/local thing sucks a bit, reorganise/redesign it
- line mode/char-at-a-time mode a la telnet? - line mode/char-at-a-time mode a la telnet?
- some of the uses of buffers really sucks. buffer_reverse_add/remove, - some of the uses of buffers really sucks. buffer_reverse_add/remove,
@ -30,6 +29,10 @@
or use queues/trees and avoid NULLs? or use queues/trees and avoid NULLs?
- client could pass tty fd up to server and then do nothing. what problems - client could pass tty fd up to server and then do nothing. what problems
would this cause? would this cause?
- cleanup/redesign IPC
IPC is arse-about-face: too much overhead. 8-byte header for each
packet... hrm. already scanning output for \e, could add an extra
byte to it for message
-- For 0.1 -------------------------------------------------------------------- -- For 0.1 --------------------------------------------------------------------
- man page - man page
@ -43,6 +46,9 @@
close window close window
kill session kill session
set status on/off set status on/off
set meta
set shell
bind key??
- fix resize (width problems with multiple clients?) - fix resize (width problems with multiple clients?)
- handle tmux in tmux (check $TMUX and abort) - handle tmux in tmux (check $TMUX and abort)
- check for some reqd terminfo caps on startup - check for some reqd terminfo caps on startup

17
input.c
View File

@ -1,4 +1,4 @@
/* $Id: input.c,v 1.16 2007-10-01 17:37:41 nicm Exp $ */ /* $Id: input.c,v 1.17 2007-10-03 00:13:46 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -1107,13 +1107,18 @@ input_store_two(struct buffer *b, u_char code, uint16_t ua, uint16_t ub)
void void
input_store8(struct buffer *b, uint8_t n) input_store8(struct buffer *b, uint8_t n)
{ {
buffer_write(b, &n, sizeof n); buffer_ensure(b, 1);
BUFFER_IN(b)[0] = n;
buffer_add(b, 1);
} }
void void
input_store16(struct buffer *b, uint16_t n) input_store16(struct buffer *b, uint16_t n)
{ {
buffer_write(b, &n, sizeof n); buffer_ensure(b, 2);
BUFFER_IN(b)[0] = n & 0xff;
BUFFER_IN(b)[1] = n >> 8;
buffer_add(b, 2);
} }
uint8_t uint8_t
@ -1121,7 +1126,8 @@ input_extract8(struct buffer *b)
{ {
uint8_t n; uint8_t n;
buffer_read(b, &n, sizeof n); n = BUFFER_OUT(b)[0];
buffer_remove(b, 1);
return (n); return (n);
} }
@ -1130,6 +1136,7 @@ input_extract16(struct buffer *b)
{ {
uint16_t n; uint16_t n;
buffer_read(b, &n, sizeof n); n = BUFFER_OUT(b)[0] | (BUFFER_OUT(b)[1] << 8);
buffer_remove(b, 2);
return (n); return (n);
} }