Ejemplo n.º 1
0
		public virtual void  TestBasic()
		{
			System.String string_Renamed = new System.Text.StringBuilder("test str").ToString();
			RamUsageEstimator rue = new RamUsageEstimator();
			long size = rue.EstimateRamUsage(string_Renamed);
			System.Console.Out.WriteLine("size:" + size);
			
			string_Renamed = new System.Text.StringBuilder("test strin").ToString();
			size = rue.EstimateRamUsage(string_Renamed);
			System.Console.Out.WriteLine("size:" + size);
			
			Holder holder = new Holder();
			holder.holder = new Holder("string2", 5000L);
			size = rue.EstimateRamUsage(holder);
			System.Console.Out.WriteLine("size:" + size);
			
			System.String[] strings = new System.String[]{new System.Text.StringBuilder("test strin").ToString(), new System.Text.StringBuilder("hollow").ToString(), new System.Text.StringBuilder("catchmaster").ToString()};
			size = rue.EstimateRamUsage(strings);
			System.Console.Out.WriteLine("size:" + size);
		}
Ejemplo n.º 2
0
        public virtual void  TestBasic()
        {
            System.String     string_Renamed = new System.Text.StringBuilder("test str").ToString();
            RamUsageEstimator rue            = new RamUsageEstimator();
            long size = rue.EstimateRamUsage(string_Renamed);

            System.Console.Out.WriteLine("size:" + size);

            string_Renamed = new System.Text.StringBuilder("test strin").ToString();
            size           = rue.EstimateRamUsage(string_Renamed);
            System.Console.Out.WriteLine("size:" + size);

            Holder holder = new Holder();

            holder.holder = new Holder("string2", 5000L);
            size          = rue.EstimateRamUsage(holder);
            System.Console.Out.WriteLine("size:" + size);

            System.String[] strings = new System.String[] { new System.Text.StringBuilder("test strin").ToString(), new System.Text.StringBuilder("hollow").ToString(), new System.Text.StringBuilder("catchmaster").ToString() };
            size = rue.EstimateRamUsage(strings);
            System.Console.Out.WriteLine("size:" + size);
        }
Ejemplo n.º 3
0
		    public LowMemoryHandlerStatistics GetStats()
		    {
			    var cacheEntries = FieldCache_Fields.DEFAULT.GetCacheEntries();
			    var memorySum = cacheEntries.Sum(x =>
			    {
				    var curEstimator = new RamUsageEstimator(false);
				    return curEstimator.EstimateRamUsage(x);
			    });
			    return new LowMemoryHandlerStatistics
			    {
					Name = "LuceneLowMemoryHandler",
					EstimatedUsedMemory = memorySum,
					Metadata = new
					{
						CachedEntriesAmount = cacheEntries.Length
					}
			    };
		    }
Ejemplo n.º 4
0
        /// <summary> Computes (and stores) the estimated size of the cache Value </summary>
        /// <seealso cref="EstimatedSize">
        /// </seealso>
        public virtual void EstimateSize(RamUsageEstimator ramCalc)
        {
            long size = ramCalc.EstimateRamUsage(Value);

            EstimatedSize = RamUsageEstimator.HumanReadableUnits(size, new System.Globalization.NumberFormatInfo());  // {{Aroush-2.9}} in Java, the formater is set to "0.#", so we need to do the same in C#
        }