Performance overhaul sponsored by rockxz3, using his large server's data for reference to help with testing and tuning. Timing numbers below are based on this data set on my test server.

* PlayerMoveEvent performance boost (from 0.047ms to 0.015ms in testing, ~313% as fast): now more thrifty in determining whether player has actually moved between chunks before doing anything else; important since this event triggers extremely quickly
* PlayerInteractEvent performance boost (from 0.068ms to 0.034ms in testing, ~200% as fast): now ignores left-clicks for interaction checks, since in CraftBukkit 1.4 left-clicks no longer open doors or activate buttons/levers/etc.; not as important as above, but still triggers quite often as people are digging or interacting with blocks
* "/f list" command performance boost (from 234ms to 30ms in testing, ~780% as fast): code was getting information for all factions, narrowed it down to only getting info for displayed page range
* "/f show" command performance boost (from 132ms to 28ms in testing, ~470% as fast): tweaked the ally & enemy listing code used
This commit is contained in:
Brettflan
2012-11-06 09:43:27 -06:00
parent d31741fb34
commit 3e0a68fd6e
6 changed files with 68 additions and 17 deletions

View File

@ -73,6 +73,8 @@ public class CmdList extends FCommand
});
ArrayList<String> lines = new ArrayList<String>();
/* // this code was really slow on large servers, getting full info for every faction and then only showing 9 of them; rewritten below
lines.add(p.txt.parse("<i>Factionless<i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
for (Faction faction : factionList)
{
@ -87,6 +89,37 @@ public class CmdList extends FCommand
}
sendMessage(p.txt.getPage(lines, this.argAsInt(0, 1), "Faction List"));
*/
factionList.add(0, Factions.i.getNone());
final int pageheight = 9;
int pagenumber = this.argAsInt(0, 1);
int pagecount = (factionList.size() / pageheight) + 1;
int start = (pagenumber - 1) * pageheight;
int end = start + pageheight;
if (end > factionList.size())
end = factionList.size();
lines.add(p.txt.titleize("Faction List "+pagenumber+"/"+pagecount));
for (Faction faction : factionList.subList(start, end))
{
if (faction.isNone())
{
lines.add(p.txt.parse("<i>Factionless<i> %d online", Factions.i.getNone().getFPlayersWhereOnline(true).size()));
continue;
}
lines.add(p.txt.parse("%s<i> %d/%d online, %d/%d/%d",
faction.getTag(fme),
faction.getFPlayersWhereOnline(true).size(),
faction.getFPlayers().size(),
faction.getLandRounded(),
faction.getPowerRounded(),
faction.getPowerMaxRounded())
);
}
sendMessage(lines);
}
}

View File

@ -93,7 +93,7 @@ public class CmdShow extends FCommand
String sepparator = p.txt.parse("<i>")+", ";
// List the relations to other factions
Map<Rel, List<String>> relationTags = faction.getFactionTagsPerRelation(fme);
Map<Rel, List<String>> relationTags = faction.getFactionTagsPerRelation(fme, true);
if (faction.getFlag(FFlag.PEACEFUL))
{