Minor fixes to the throughput

This commit is contained in:
tobspr 2020-06-27 16:40:51 +02:00
parent 84417b60a5
commit de0b305276
4 changed files with 36 additions and 11 deletions

View File

@ -38,7 +38,7 @@ export const globalConfig = {
// Production analytics
statisticsGraphDpi: 2.5,
statisticsGraphSlices: 100,
analyticsSliceDurationSeconds: 10,
analyticsSliceDurationSeconds: G_IS_DEV ? 1 : 10,
minimumTickRate: 25,
maximumTickRate: 500,

View File

@ -126,8 +126,23 @@ export class BeltPath extends BasicSerializableObject {
*/
tryAcceptItem(item) {
if (this.spacingToFirstItem >= globalConfig.itemSpacingOnBelts) {
this.items.unshift([this.spacingToFirstItem, item]);
this.spacingToFirstItem = 0;
// So, since we already need one tick to accept this item we will add this directly.
const beltProgressPerTick =
this.root.hubGoals.getBeltBaseSpeed() *
this.root.dynamicTickrate.deltaSeconds *
globalConfig.itemSpacingOnBelts;
// First, compute how much progress we can make *at max*
const maxProgress = Math.max(0, this.spacingToFirstItem - globalConfig.itemSpacingOnBelts);
const initialProgress = Math.min(maxProgress, beltProgressPerTick);
this.items.unshift([this.spacingToFirstItem - initialProgress, item]);
this.spacingToFirstItem = initialProgress;
if (G_IS_DEV && globalConfig.debug.checkBeltPaths) {
this.debug_checkIntegrity("accept-item");
}
return true;
}
return false;

View File

@ -1,8 +1,7 @@
import { gItemRegistry } from "../../core/global_registries";
import { types } from "../../savegame/serialization";
import { BaseItem } from "../base_item";
import { Component } from "../component";
import { enumDirection, Vector } from "../../core/vector";
import { types } from "../../savegame/serialization";
import { gItemRegistry } from "../../core/global_registries";
/** @enum {string} */
export const enumItemProcessorTypes = {
@ -102,6 +101,12 @@ export class ItemProcessorComponent extends Component {
* @param {number} sourceSlot
*/
tryTakeItem(item, sourceSlot) {
if (this.type === enumItemProcessorTypes.hub || this.type === enumItemProcessorTypes.trash) {
// Hub has special logic .. not really nice but efficient.
this.inputSlots.push({ item, sourceSlot });
return true;
}
// Check that we only take one item per slot
for (let i = 0; i < this.inputSlots.length; ++i) {
const slot = this.inputSlots[i];

View File

@ -1,10 +1,10 @@
import { makeOffscreenBuffer } from "../../../core/buffer_utils";
import { globalConfig } from "../../../core/config";
import { clamp, formatBigNumber, round2Digits } from "../../../core/utils";
import { T } from "../../../translations";
import { enumAnalyticsDataSource } from "../../production_analytics";
import { GameRoot } from "../../root";
import { ShapeDefinition } from "../../shape_definition";
import { enumAnalyticsDataSource } from "../../production_analytics";
import { formatBigNumber, clamp } from "../../../core/utils";
import { globalConfig } from "../../../core/config";
import { makeOffscreenBuffer } from "../../../core/buffer_utils";
import { T } from "../../../translations";
/** @enum {string} */
export const enumDisplayMode = {
@ -91,6 +91,11 @@ export class HUDShapeStatisticsHandle {
"<shapes>",
formatBigNumber(rate)
);
if (G_IS_DEV && globalConfig.debug.detailedStatistics) {
this.counter.innerText = "" + round2Digits(rate / 60) + " /s";
}
break;
}
}