Mapper module draw slowness

Posted by Ircria on Sat 01 Sep 2012 06:00 PM — 4 posts, 16,878 views.

#0
Hello,

While working with mapper.lua, I've noticed an unusual amount of slowness in the draw function. I'm unsure if it's just my settings or what, but I'm currently wondering if there would be a way to speed it up. The draw function is unedited, save for a check to see if the window is hidden before drawing it.
I apologize for any vagueness from this, or if this is a common complaint. I really do feel this is user error on my part, but I just wanted to be sure.

Profile after moving one room:
                 Function    Count  Seconds

                     draw        6   0.1020
               WindowLine     2184   0.0183
           WindowCircleOp     1086   0.0084
         WindowAddHotspot      552   0.0060
             WindowCreate        6   0.0042


Current settings:
map.default_mapconfig = {
	-- assorted colours
	BACKGROUND_COLOUR			= { name = "Background",	colour = 	ColourNameToRGB "lightseagreen", },
	ROOM_COLOUR					= { name = "Room",			colour =	ColourNameToRGB "cyan", },
	EXIT_COLOUR					= { name = "Exit",			colour =	ColourNameToRGB "darkgreen", },
	EXIT_COLOUR_UP_DOWN		 	= { name = "Exit up/down",	colour =	ColourNameToRGB "darkmagenta", },
	EXIT_COLOUR_IN_OUT			= { name = "Exit in/out",	colour =	ColourNameToRGB "#3775E8", },
	OUR_ROOM_COLOUR				= { name = "Our room",		colour =	ColourNameToRGB "black", },
	UNKNOWN_ROOM_COLOUR		 	= { name = "Unknown room",	colour =	ColourNameToRGB "#00CACA", },
	DIFFERENT_AREA_COLOUR	 	= { name = "Another area",	colour =	ColourNameToRGB "#009393", },
	SHOP_FILL_COLOUR			= { name = "Shop",			colour =	ColourNameToRGB "darkolivegreen", },
	POSTOFFICE_FILL_COLOUR		= { name = "Post Office",	colour =	ColourNameToRGB "yellowgreen", },
	BANK_FILL_COLOUR			= { name = "Bank",			colour =	ColourNameToRGB "gold", },
	NEWSROOM_FILL_COLOUR		= { name = "Newsroom",		colour =	ColourNameToRGB "lightblue", },
	MAPPER_NOTE_COLOUR			= { name = "Messages",		colour =	ColourNameToRGB "lightgreen" },
	
	ROOM_NAME_TEXT				= { name = "Room name text",colour = ColourNameToRGB "#BEF3F1", },
	ROOM_NAME_FILL				= { name = "Room name fill",colour = ColourNameToRGB "#105653", },
	ROOM_NAME_BORDER			= { name = "Room name box",	colour = ColourNameToRGB "black", },
	
	AREA_NAME_TEXT				= { name = "Area name text",colour = ColourNameToRGB "#BEF3F1",},
	AREA_NAME_FILL				= { name = "Area name fill",colour = ColourNameToRGB "#105653", },	 
	AREA_NAME_BORDER			= { name = "Area name box",	colour = ColourNameToRGB "black", },
	
	FONT = {
		name = get_preferred_font {"Dina", "Lucida Console", "Fixedsys", "Courier", "Sylfaen",} ,
		size = 8
	},
				 
	-- size of map window
	WINDOW = { width = 400, height = 400 },
	
	-- how far from where we are standing to draw (rooms)
	SCAN = { depth = 10},
	
	-- speedwalk delay
	DELAY = { time = 0.3 },
	
	-- how many seconds to show "recent visit" lines (default 3 minutes)
	LAST_VISIT_TIME = { time = 60 * 3 },	
}


Image of map for scale: http://i.imgur.com/aRURV.png

Any advice would be appreciated.

Thank you.
#1
Er, yes. It did seem to be user error. I was calling mapper.draw 13 times per movement. Please disregard my idiocy, and my apologies for taking up your time
USA Global Moderator #2
I know this is subjective (Nick knows I can be a pain about performance) but IMO it's not just you. The mapper, like many of Nick's cooler plugin modules, was made as an example work to get user_developers started and motivated. There are many places in both the lua module and associated plugin where significant performance gains can be achieved through more efficient techniques (like making fewer, larger DB requests). Nick's take on plugin performance has historically been "good enough is good enough". And if you want something more, then it's up to you to work out the details. :)
Australia Forum Administrator #3
I agree with Fiendish that there is probably room for improvement. Mind you, I'd want to measure that. The fewer DB requests may or may not make an observable difference.

You could probably cache stuff (I thought it did that already) so that once you have a room from the database it is read from memory next time.

To his credit, Fiendish has taken the original plugin and miniwindow concepts and made some rather stunning, and highly integrated, plugins.