Esempio n. 1
0
        private long CollectClassStats(FileUsageStats stats, ClassNode classNode)
        {
            long subClassSlotUsage = 0;

            for (IEnumerator curSubClassIter = classNode.SubClasses().GetEnumerator(); curSubClassIter
                 .MoveNext();)
            {
                ClassNode curSubClass = ((ClassNode)curSubClassIter.Current);
                subClassSlotUsage += CollectClassStats(stats, curSubClass);
            }
            ClassMetadata clazz           = classNode.ClassMetadata();
            long          classIndexUsage = 0;

            if (clazz.HasClassIndex())
            {
                classIndexUsage = BTreeUsage(((BTreeClassIndexStrategy)clazz.Index()).Btree());
            }
            long fieldIndexUsage = FieldIndexUsage(clazz);

            FileUsageStatsCollector.InstanceUsage instanceUsage = ClassSlotUsage(clazz);
            long            totalSlotUsage = instanceUsage.slotUsage;
            long            ownSlotUsage   = totalSlotUsage - subClassSlotUsage;
            ClassUsageStats classStats     = new ClassUsageStats(clazz.GetName(), ownSlotUsage, classIndexUsage
                                                                 , fieldIndexUsage, instanceUsage.miscUsage);

            stats.AddClassStats(classStats);
            return(totalSlotUsage);
        }
Esempio n. 2
0
        /// <summary>Usage: FileUsageStatsCollector <db path> [<collect gaps (true|false)>]</summary>
        public static void Main(string[] args)
        {
            string dbPath       = args[0];
            bool   collectSlots = args.Length > 1 && "true".Equals(args[1]);

            Sharpen.Runtime.Out.WriteLine(dbPath + ": " + new Sharpen.IO.File(dbPath).Length(
                                              ));
            FileUsageStats stats = RunStats(dbPath, collectSlots);

            Sharpen.Runtime.Out.WriteLine(stats);
        }
Esempio n. 3
0
 public virtual FileUsageStats CollectStats()
 {
     _stats = new FileUsageStats(_db.FileLength(), FileHeaderUsage(), IdSystemUsage(),
                                 Freespace(), ClassMetadataUsage(), FreespaceUsage(), UuidUsage(), _slots, CommitTimestampUsage
                                     ());
     Sharpen.Util.ISet classRoots = ClassNode.BuildHierarchy(_db.ClassCollection());
     for (IEnumerator classRootIter = classRoots.GetEnumerator(); classRootIter.MoveNext
              ();)
     {
         ClassNode classRoot = ((ClassNode)classRootIter.Current);
         CollectClassSlots(classRoot.ClassMetadata());
         CollectClassStats(_stats, classRoot);
     }
     return(_stats);
 }
Esempio n. 4
0
		private long CollectClassStats(FileUsageStats stats, ClassNode classNode)
		{
			long subClassSlotUsage = 0;
			for (IEnumerator curSubClassIter = classNode.SubClasses().GetEnumerator(); curSubClassIter
				.MoveNext(); )
			{
				ClassNode curSubClass = ((ClassNode)curSubClassIter.Current);
				subClassSlotUsage += CollectClassStats(stats, curSubClass);
			}
			ClassMetadata clazz = classNode.ClassMetadata();
			long classIndexUsage = 0;
			if (clazz.HasClassIndex())
			{
				classIndexUsage = BTreeUsage(((BTreeClassIndexStrategy)clazz.Index()).Btree());
			}
			long fieldIndexUsage = FieldIndexUsage(clazz);
			FileUsageStatsCollector.InstanceUsage instanceUsage = ClassSlotUsage(clazz);
			long totalSlotUsage = instanceUsage.slotUsage;
			long ownSlotUsage = totalSlotUsage - subClassSlotUsage;
			ClassUsageStats classStats = new ClassUsageStats(clazz.GetName(), ownSlotUsage, classIndexUsage
				, fieldIndexUsage, instanceUsage.miscUsage);
			stats.AddClassStats(classStats);
			return totalSlotUsage;
		}
Esempio n. 5
0
		public virtual FileUsageStats CollectStats()
		{
			_stats = new FileUsageStats(_db.FileLength(), FileHeaderUsage(), IdSystemUsage(), 
				Freespace(), ClassMetadataUsage(), FreespaceUsage(), UuidUsage(), _slots, CommitTimestampUsage
				());
			Sharpen.Util.ISet classRoots = ClassNode.BuildHierarchy(_db.ClassCollection());
			for (IEnumerator classRootIter = classRoots.GetEnumerator(); classRootIter.MoveNext
				(); )
			{
				ClassNode classRoot = ((ClassNode)classRootIter.Current);
				CollectClassSlots(classRoot.ClassMetadata());
				CollectClassStats(_stats, classRoot);
			}
			return _stats;
		}