public void BenchmarkTimedExpiry()
        {
            SixLabors.ImageSharp.Configuration.Default.MemoryAllocator = ArrayPoolMemoryAllocator.CreateDefault();

            using (var store = new TimedExpiryGlyphStore(baseResources, font_name))
                runFor(store);
        }
Esempio n. 2
0
        public SharpImageFactory(SmartConfiguration appConfig)
        {
            switch (appConfig.ImagingMemoryAllocation)
            {
            case ImagingMemoryAllocation.Minimal:
                _memAllocator = ArrayPoolMemoryAllocator.CreateWithMinimalPooling();
                break;

            case ImagingMemoryAllocation.Moderate:
                _memAllocator = ArrayPoolMemoryAllocator.CreateWithModeratePooling();
                break;

            case ImagingMemoryAllocation.Default:
                _memAllocator = ArrayPoolMemoryAllocator.CreateDefault();
                break;

            case ImagingMemoryAllocation.Aggressive:
                _memAllocator = ArrayPoolMemoryAllocator.CreateWithAggressivePooling();
                break;
            }

            SharpConfiguration.Default.MemoryAllocator = _memAllocator;

            // Release memory pool every 10 minutes
            var releaseInterval = TimeSpan.FromMinutes(10);

            _releaseMemTimer = new Timer(o => ReleaseMemory(), null, releaseInterval, releaseInterval);
        }
        public override void SetUp()
        {
            SixLabors.ImageSharp.Configuration.Default.MemoryAllocator = ArrayPoolMemoryAllocator.CreateDefault();

            baseResources = new NamespacedResourceStore <byte[]>(new DllResourceStore(@"osu.Framework.dll"), @"Resources");
            sharedTemp    = new TemporaryNativeStorage("fontstore-test-" + Guid.NewGuid());
        }
Esempio n. 4
0
            private void LimitBufferCapacity(int bufferCapacityInBytes)
            {
                var allocator = ArrayPoolMemoryAllocator.CreateDefault();

                this.configuration.MemoryAllocator = allocator;
                allocator.BufferCapacityInBytes    = bufferCapacityInBytes;
            }
        public ImageService(IHostingEnvironment hostingEnvironment)
        {
            _hostingEnvironment = hostingEnvironment;

            uploadsFolder = Path.Combine(_hostingEnvironment.WebRootPath, @"img\uploads");

            Configuration.Default.MemoryAllocator = ArrayPoolMemoryAllocator.CreateDefault();
        }
Esempio n. 6
0
        internal static AllocatorBufferCapacityConfigurator LimitAllocatorBufferCapacity <TPixel>(
            this TestImageProvider <TPixel> provider)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            var allocator = ArrayPoolMemoryAllocator.CreateDefault();

            provider.Configuration.MemoryAllocator = allocator;
            return(new AllocatorBufferCapacityConfigurator(allocator, Unsafe.SizeOf <TPixel>()));
        }
Esempio n. 7
0
        internal static void RunBufferCapacityLimitProcessorTest <TPixel>(
            this TestImageProvider <TPixel> provider,
            int bufferCapacityInPixelRows,
            Action <IImageProcessingContext> process,
            object testOutputDetails = null,
            ImageComparer comparer   = null)
            where TPixel : unmanaged, IPixel <TPixel>
        {
            comparer ??= ImageComparer.Exact;
            using Image <TPixel> expected = provider.GetImage();
            int width = expected.Width;

            expected.Mutate(process);

            var allocator = ArrayPoolMemoryAllocator.CreateDefault();

            provider.Configuration.MemoryAllocator = allocator;
            allocator.BufferCapacityInBytes        = bufferCapacityInPixelRows * width * Unsafe.SizeOf <TPixel>();

            using Image <TPixel> actual = provider.GetImage();
            actual.Mutate(process);
            comparer.VerifySimilarity(expected, actual);
        }