Package nallar.tickthreading.util

Examples of nallar.tickthreading.util.TableFormatter


  public static void profile(final ICommandSender commandSender, int seconds) {
    final UtilisationProfiler contentionProfiler = new UtilisationProfiler(seconds);
    contentionProfiler.run(new Runnable() {
      @Override
      public void run() {
        TableFormatter tf = new TableFormatter(commandSender);
        contentionProfiler.dump(tf, commandSender instanceof MinecraftServer ? 15 : 6);
        Command.sendChat(commandSender, tf.toString());
      }
    });
  }
View Full Code Here


      public void run() {
        try {
          Thread.sleep(time * 1000);
        } catch (InterruptedException ignored) {
        }
        Command.sendChat(commandSender, writeStats(new TableFormatter(commandSender)).toString());
        synchronized (PacketProfiler.class) {
          size.clear();
          count.clear();
          profiling = false;
        }
View Full Code Here

            tickRegion = manager.getTileEntityRegion(hashCode);
            if (tickRegion != null) {
              tickRegion.profilingEnabled = false;
            }
          }
          sendChat(commandSender, entityTickProfiler.writeStringData(new TableFormatter(commandSender)).toString());
        }
      }, location ? ProfilingState.CHUNK : ProfilingState.GLOBAL, time, worlds)) {
        sendChat(commandSender, "Someone else is currently profiling.");
      }
      if (location) {
        manager.profilingEnabled = false;
        TickRegion tickRegion = manager.getEntityRegion(hashCode);
        if (tickRegion != null) {
          tickRegion.profilingEnabled = true;
        }
        tickRegion = manager.getTileEntityRegion(hashCode);
        if (tickRegion != null) {
          tickRegion.profilingEnabled = true;
        }
      }
      sendChat(commandSender, "Profiling for " + time + " seconds in " + (world == null ? "all worlds " : Log.name(world)) + (location ? " at chunk coords " + x + ',' + z : ""));
      return;
    }
    if (Timings.enabled) {
      sendChat(commandSender, "Someone else is currently profiling, please wait and try again.");
      return;
    }
    Timings.enabled = true;
    Runnable profilingRunnable = new Runnable() {
      @Override
      public void run() {
        try {
          Thread.sleep(1000 * time);
        } catch (InterruptedException ignored) {
        }
        Timings.enabled = false;
        try {
          Thread.sleep(100 * time);
        } catch (InterruptedException ignored) {
        }
        sendChat(commandSender, String.valueOf(Timings.writeData(new TableFormatter(commandSender))));
        Timings.clear();
      }
    };
    Thread profilingThread = new Thread(profilingRunnable);
    profilingThread.setName("TT Profiler");
View Full Code Here

  public static void profile(final ICommandSender commandSender, int seconds, int resolution) {
    final ContentionProfiler contentionProfiler = new ContentionProfiler(seconds, resolution);
    contentionProfiler.run(new Runnable() {
      @Override
      public void run() {
        TableFormatter tf = new TableFormatter(commandSender);
        contentionProfiler.dump(tf, commandSender instanceof MinecraftServer ? 15 : 6);
        Command.sendChat(commandSender, tf.toString());
      }
    });
  }
View Full Code Here

      EntityPlayer entityPlayer = event.entityPlayer;
      ItemStack usedItem = entityPlayer.getCurrentEquippedItem();
      if (usedItem != null) {
        Item usedItemType = usedItem.getItem();
        if (usedItemType == Item.pocketSundial && (!requireOpForDumpCommand || entityPlayer.canCommandSenderUseCommand(4, "dump"))) {
          Command.sendChat(entityPlayer, DumpCommand.dump(new TableFormatter(entityPlayer), entityPlayer.worldObj, event.x, event.y, event.z, 35).toString());
          event.setCanceled(true);
        }
      }
    }
  }
View Full Code Here

  }

  @Override
  public void processCommand(ICommandSender commandSender, List<String> arguments) {
    StatsHolder statsHolder = new StatsHolder();
    TableFormatter tf = new TableFormatter(commandSender);
    tf.sb.append(VersionUtil.TTVersionString()).append('\n');
    tf
        .heading("")
        .heading("E")
        .heading("TE")
        .heading("C")
        .heading("P")
        .heading("L");
    for (TickManager tickManager : TickThreading.instance.getManagers()) {
      tickManager.writeStats(tf, statsHolder);
    }
    tf
        .row("Overall")
        .row(statsHolder.entities)
        .row(statsHolder.tileEntities)
        .row(statsHolder.chunks)
        .row(MinecraftServer.getServerConfigurationManager(MinecraftServer.getServer()).getCurrentPlayerCount())
        .row(TableFormatter.formatDoubleWithPrecision((MinecraftServer.getTickTime() * 100) / MinecraftServer.getTargetTickTime(), 2) + '%');
    tf.finishTable();
    tf.sb.append('\n').append(getTPSString(commandSender instanceof EntityPlayer));
    sendChat(commandSender, tf.toString());
  }
View Full Code Here

      ticks++;
    }
  }

  public void writeJSONData(File file) throws IOException {
    TableFormatter tf = new TableFormatter(StringFiller.FIXED_WIDTH);
    tf.recordTables();
    writeData(tf, 20);
    ObjectMapper objectMapper = new ObjectMapper();
    List<Object> tables = tf.getTables();
    long timeProfiled = System.currentTimeMillis() - startTime;
    float tps = ticks * 1000f / timeProfiled;
    tables.add(0, CollectionsUtil.map(
        "TPS", tps,
        "Load", TableFormatter.formatDoubleWithPrecision((MinecraftServer.getTickTime() * 100) / MinecraftServer.getTargetTickTime(), 2)
View Full Code Here

    }
    if (world == null) {
      sendChat(commandSender, usage());
      return;
    }
    sendChat(commandSender, dump(new TableFormatter(commandSender), world, x, y, z, commandSender instanceof Entity ? 35 : 70).toString());
  }
View Full Code Here

      if (arguments.size() == 2) {
        region = TickManager.getHashCode(Integer.parseInt(arguments.remove(0)), Integer.parseInt(arguments.remove(0)));
      } else if (commandSender instanceof Entity) {
        region = TickManager.getHashCode((Entity) commandSender);
      }
      sendChat(commandSender, String.valueOf(TickThreading.instance.getManager(DimensionManager.getWorld(worldId)).writeRegionDetails(new TableFormatter(commandSender), region)));
      return;
    }
    World world;
    try {
      world = getWorld(commandSender, arguments);
    } catch (Exception e) {
      world = null;
    }
    if (world == null) {
      sendChat(commandSender, usage());
      return;
    }
    if ("e".equals(type)) {
      TableFormatter tf = new TableFormatter(commandSender);
      TickManager tickManager = TickThreading.instance.getManager(world);
      tickManager.writeEntityStats(tf);
      tf.sb.append('\n');
      tickManager.fixDiscrepancies(tf.sb);
      sendChat(commandSender, String.valueOf(tf));
    } else if ("b".equals(type)) {
      sendChat(commandSender, String.valueOf(((WorldServer) world).writePendingBlockUpdatesStats(new TableFormatter(commandSender))));
    } else if ("t".equals(type)) {
      sendChat(commandSender, String.valueOf(TickThreading.instance.getManager(world).writeDetailedStats(new TableFormatter(commandSender))));
    } else if ("l".equals(type)) {
      sendChat(commandSender, String.valueOf(TickThreading.instance.getManager(world).writeTECounts(new TableFormatter(commandSender))));
    } else {
      sendChat(commandSender, usage());
    }
  }
View Full Code Here

      final EntityTickProfiler entityTickProfiler = EntityTickProfiler.ENTITY_TICK_PROFILER;
      entityTickProfiler.startProfiling(new Runnable() {
        @Override
        public void run() {
          try {
            TableFormatter tf = new TableFormatter(MinecraftServer.getServer());
            tf.tableSeparator = "\n";
            if (json) {
              entityTickProfiler.writeJSONData(profilingFile);
            } else {
              Files.write(entityTickProfiler.writeStringData(tf, 6).toString(), profilingFile, Charsets.UTF_8);
View Full Code Here

TOP

Related Classes of nallar.tickthreading.util.TableFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.