mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 16:54:22 +00:00
Time each bar in the loading screen and print it to the log, useful information to see where most time is spent in loading.
This commit is contained in:
1 parent
e519278888
commit
7041fbc27e
5 files changed
+42
-6
No files matched your search
@@ -64,7 +64,7 @@
|
||||
this.field_110451_am.func_110542_a(this.field_71464_q);
|
||||
this.field_110451_am.func_110542_a(new GrassColorReloadListener());
|
||||
this.field_110451_am.func_110542_a(new FoliageColorReloadListener());
|
||||
+ cpw.mods.fml.common.ProgressManager.ProgressBar bar= cpw.mods.fml.common.ProgressManager.push("Rendering Setup", 9);
|
||||
+ cpw.mods.fml.common.ProgressManager.ProgressBar bar= cpw.mods.fml.common.ProgressManager.push("Rendering Setup", 9, true);
|
||||
+ bar.step("Loading Render Manager");
|
||||
RenderManager.field_78727_a.field_78721_f = new ItemRenderer(this);
|
||||
+ bar.step("Loading Entity Renderer");
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
public void func_110541_a(List p_110541_1_)
|
||||
{
|
||||
this.func_110543_a();
|
||||
+ cpw.mods.fml.common.ProgressManager.ProgressBar resReload = cpw.mods.fml.common.ProgressManager.push("Loading Resources", p_110541_1_.size()+1);
|
||||
+ cpw.mods.fml.common.ProgressManager.ProgressBar resReload = cpw.mods.fml.common.ProgressManager.push("Loading Resources", p_110541_1_.size()+1, true);
|
||||
field_147967_a.info("Reloading ResourceManager: " + field_130074_a.join(Iterables.transform(p_110541_1_, new Function()
|
||||
{
|
||||
private static final String __OBFID = "CL_00001092";
|
||||
|
||||
@@ -363,7 +363,7 @@ public class SplashProgress
|
||||
drawBox(barWidth - 2, barHeight - 2);
|
||||
// slidy part
|
||||
setColor(barColor);
|
||||
drawBox((barWidth - 2) * b.getStep() / b.getSteps(), barHeight - 2);
|
||||
drawBox((barWidth - 2) * (b.getStep() + 1) / (b.getSteps() + 1), barHeight - 2); // Step can sometimes be 0.
|
||||
// progress text
|
||||
String progress = "" + b.getStep() + "/" + b.getSteps();
|
||||
glTranslatef(((float)barWidth - 2) / 2 - fontRenderer.getStringWidth(progress), 2, 0);
|
||||
@@ -766,4 +766,4 @@ public class SplashProgress
|
||||
}
|
||||
return mcPack.getInputStream(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,7 +183,7 @@ public class LoadController
|
||||
{
|
||||
modObjectList = buildModObjectList();
|
||||
}
|
||||
ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size());
|
||||
ProgressBar bar = ProgressManager.push(stateEvent.description(), activeModList.size(), true);
|
||||
for (ModContainer mc : activeModList)
|
||||
{
|
||||
bar.step(mc.getName());
|
||||
|
||||
@@ -19,9 +19,21 @@ public class ProgressManager
|
||||
*/
|
||||
@Deprecated
|
||||
public static ProgressBar push(String title, int steps)
|
||||
{
|
||||
return push(title, steps, false);
|
||||
}
|
||||
/**
|
||||
* @deprecated not a stable API, will break, don't use this yet
|
||||
*/
|
||||
@Deprecated
|
||||
public static ProgressBar push(String title, int steps, boolean timeEachStep)
|
||||
{
|
||||
ProgressBar bar = new ProgressBar(title, steps);
|
||||
bars.add(bar);
|
||||
if (timeEachStep)
|
||||
{
|
||||
bar.timeEachStep();
|
||||
}
|
||||
FMLCommonHandler.instance().processWindowMessages();
|
||||
return bar;
|
||||
}
|
||||
@@ -34,6 +46,16 @@ public class ProgressManager
|
||||
{
|
||||
if(bar.getSteps() != bar.getStep()) throw new IllegalStateException("can't pop unfinished ProgressBar " + bar.getTitle());
|
||||
bars.remove(bar);
|
||||
if (bar.getSteps() != 0)
|
||||
{
|
||||
long newTime = System.nanoTime();
|
||||
if (bar.timeEachStep)
|
||||
FMLLog.fine("Bar Step: %s - %s took %.3fs", bar.getTitle(), bar.getMessage(), ((float)(newTime - bar.lastTime) / 1000000 / 1000));
|
||||
if (bar.getSteps() == 1)
|
||||
FMLLog.fine("Bar Finished: %s - %s took %.3fs", bar.getTitle(), bar.getMessage(), ((float)(newTime - bar.startTime) / 1000000 / 1000));
|
||||
else
|
||||
FMLLog.fine("Bar Finished: %s took %.3fs", bar.getTitle(), ((float)(newTime - bar.startTime) / 1000000 / 1000));
|
||||
}
|
||||
FMLCommonHandler.instance().processWindowMessages();
|
||||
}
|
||||
|
||||
@@ -55,6 +77,9 @@ public class ProgressManager
|
||||
private final int steps;
|
||||
private volatile int step = 0;
|
||||
private volatile String message = "";
|
||||
private boolean timeEachStep = false;
|
||||
private long startTime = System.nanoTime();
|
||||
private long lastTime = startTime;
|
||||
|
||||
private ProgressBar(String title, int steps)
|
||||
{
|
||||
@@ -70,6 +95,12 @@ public class ProgressManager
|
||||
public void step(String message)
|
||||
{
|
||||
if(step >= steps) throw new IllegalStateException("too much steps for ProgressBar " + title);
|
||||
if (timeEachStep && step != 0)
|
||||
{
|
||||
long newTime = System.nanoTime();
|
||||
FMLLog.fine("Bar Step: %s - %s took %.3fs", getTitle(), getMessage(), ((float)(newTime - lastTime) / 1000000 / 1000));
|
||||
lastTime = newTime;
|
||||
}
|
||||
step++;
|
||||
this.message = FMLCommonHandler.instance().stripSpecialChars(message);
|
||||
FMLCommonHandler.instance().processWindowMessages();
|
||||
@@ -94,5 +125,10 @@ public class ProgressManager
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
public void timeEachStep()
|
||||
{
|
||||
this.timeEachStep = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user