# Benchmarks
For the purposes of approximate comparison between _MetadataExtractor_ and .NET Framework alternatives,
multiple scenarios are benchmarked. These focus on retrieving the "DateTimeOriginal" Exif value,
as that is a common use case for this library.
## Running
From the directory containing this README file:
dotnet run -c Release
## Results
Results resemble (as of November 2016):
```plain
Host Process Environment Information:
BenchmarkDotNet.Core=v0.9.9.0
OS=Microsoft Windows NT 6.2.9200.0
Processor=Intel(R) Core(TM) i7-6700HQ CPU 2.60GHz, ProcessorCount=8
Frequency=2531248 ticks, Resolution=395.0620 ns, Timer=TSC
CLR=MS.NET 4.0.30319.42000, Arch=64-bit RELEASE [RyuJIT]
GC=Concurrent Workstation
JitModules=clrjit-v4.6.1586.0
Type=JpegBenchmark Mode=Throughput
Method | Median | StdDev | Scaled | Scaled-SD |
------------------------------------------ |------------ |----------- |------- |---------- |
JpegMetadataReaderOnlyExifReaderBenchmark | 30.1141 us | 0.7083 us | 1.00 | 0.00 |
JpegMetadataReaderBenchmark | 49.0014 us | 2.9799 us | 1.64 | 0.10 |
ImageMetadataReaderBenchmark | 48.3592 us | 1.2577 us | 1.60 | 0.05 |
SystemDrawingBenchmark | 322.4140 us | 7.2245 us | 10.62 | 0.33 |
WpfBitmapFrameCreateBenchmark | 678.8931 us | 13.3292 us | 22.36 | 0.65 |
WpfJpegBitmapDecoderBenchmark | 934.4390 us | 18.2268 us | 30.75 | 0.89 |
```
The most indicative measure of throughput comes from the _Median_ column, where lower values are better.
Note that `us` indicates µs (microseconds, thousandths of milliseconds, or 10<sup>-6</sup> seconds).
For these benchmarks, image data is loaded into a `MemoryStream` which is reused between test runs.
In general, IO will be the major limiting factor, and that is excluded by pre-loading data, however
it does minimise external influences on the results. _MetadataExtractor_ is careful to avoid
unnecessary IO.
---
#### JpegMetadataReaderOnlyExifReaderBenchmark
If you know you have JPEG data, and you only want Exif data, this is a fast option:
var directories = JpegMetadataReader.ReadMetadata(_stream, new[] { new ExifReader() });
var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().First();
var dateTime = subIfdDirectory.GetDateTime(ExifDirectoryBase.TagDateTimeOriginal);
Other kinds of metadata in the file will be ignored. Throws if the file does not actually contain JPEG data.
#### JpegMetadataReaderBenchmark
Retrieves all metadata from a JPEG file.
var directories = JpegMetadataReader.ReadMetadata(_stream);
var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().First();
var dateTime = subIfdDirectory.GetDateTime(ExifDirectoryBase.TagDateTimeOriginal);
Throws if the file does not contain JPEG data.
#### ImageMetadataReaderBenchmark
Determines the file type automatically, then proceeds to return all found metadata.
var directories = ImageMetadataReader.ReadMetadata(_stream);
var subIfdDirectory = directories.OfType<ExifSubIfdDirectory>().First();
var dateTime = subIfdDirectory.GetDateTime(ExifDirectoryBase.TagDateTimeOriginal);
This is the most general solution, and is recommended for most use cases. Throws if the file does not contain a supported file type.
#### SystemDrawingBenchmark
Using `System.Drawing` is ~1,000% slower.
using (var myImage = Image.FromStream(_stream, useEmbeddedColorManagement: false, validateImageData: false))
{
const int PropertyTagExifDTOrig = ExifDirectoryBase.TagDateTimeOriginal;
var propItem = myImage.GetPropertyItem(PropertyTagExifDTOrig);
var dateTakenStr = Encoding.UTF8.GetString(propItem.Value);
var dateTime = DateTime.Parse(_dateTimeRegex.Replace(dateTakenStr, "-", count: 2));
}
#### WpfBitmapFrameCreateBenchmark
Using WPF's `BitmapFrame` is ~2,200% slower.
var frame = BitmapFrame.Create(_stream, BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
var metadata = (BitmapMetadata)frame.Metadata;
var dateTakenStr = (string)metadata.GetQuery("/app1/ifd/exif/subifd:{uint=36867}");
var dateTime DateTime.Parse(_dateTimeRegex.Replace(dateTakenStr, "-", count: 2));
#### WpfJpegBitmapDecoderBenchmark
Using WPF's `JpegBitmapDecoder` is ~3,000% slower.
var decoder = new JpegBitmapDecoder(_stream, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.None);
var metadata = (BitmapMetadata)decoder.Frames[0].Metadata;
var dateTakenStr = (string)metadata.GetQuery("/app1/ifd/exif/subifd:{uint=36867}");
var dateTime DateTime.Parse(_dateTimeRegex.Replace(dateTakenStr, "-", count: 2));
没有合适的资源?快使用搜索试试~ 我知道了~
MagicFile 是一个集文件命名和元数据管理于一身的文件管理工具。.zip
共1666个文件
cs:1083个
png:273个
jpg:42个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 141 浏览量
2024-01-02
23:42:42
上传
评论
收藏 169.78MB ZIP 举报
温馨提示
使用c#开发的系统项目源码、数据集
资源推荐
资源详情
资源评论
收起资源包目录
MagicFile 是一个集文件命名和元数据管理于一身的文件管理工具。.zip (1666个子文件)
sonyType6.jpg.app4.0 64KB
sonyType6.jpg.app4.0 64KB
sonyType6.jpg.app1.0 60KB
sonyType6.jpg.app1.0 60KB
withXmpAndIptc.jpg.app1.0 11KB
withXmpAndIptc.jpg.app1.0 11KB
adobeJpeg1.jpg.app1.0 8KB
adobeJpeg1.jpg.app1.0 8KB
withExifAndIptc.jpg.app1.0 5KB
withExifAndIptc.jpg.app1.0 5KB
sonyType6.jpg.app4.1 48KB
sonyType6.jpg.app4.1 48KB
withXmpAndIptc.jpg.app1.1 11KB
withXmpAndIptc.jpg.app1.1 11KB
withExifAndIptc.jpg.app1.1 8KB
withExifAndIptc.jpg.app1.1 8KB
adobeJpeg1.jpg.app1.1 6KB
adobeJpeg1.jpg.app1.1 6KB
sonyType6.jpg.app1.1 3KB
sonyType6.jpg.app1.1 3KB
noExif.jpg.app0 14B
adobeJpeg1.jpg.app0 14B
withExifAndIptc.jpg.app0 14B
windowsXpFields.jpg.app0 14B
nikonMakernoteType1.jpg.app0 14B
noExif.jpg.app0 14B
adobeJpeg1.jpg.app0 14B
withExifAndIptc.jpg.app0 14B
windowsXpFields.jpg.app0 14B
nikonMakernoteType1.jpg.app0 14B
repeatedOrientationTagWithDifferentValues.jpg.app1 63KB
repeatedOrientationTagWithDifferentValues.jpg.app1 63KB
nikonMakernoteType2a.jpg.app1 35KB
nikonMakernoteType2a.jpg.app1 35KB
withPanasonicFaces.jpg.app1 31KB
withPanasonicFaces.jpg.app1 31KB
nikonMakernoteType2b.jpg.app1 26KB
nikonMakernoteType2b.jpg.app1 26KB
withUncompressedRGBThumbnail.jpg.app1 21KB
withUncompressedRGBThumbnail.jpg.app1 21KB
recursiveDirectories.jpg.app1 18KB
recursiveDirectories.jpg.app1 18KB
sonyType1.jpg.app1 12KB
sonyType1.jpg.app1 12KB
nikonMakernoteType1.jpg.app1 7KB
nikonMakernoteType1.jpg.app1 7KB
simple.jpg.app1 4KB
simple.jpg.app1 4KB
withExif.jpg.app1 3KB
withExif.jpg.app1 3KB
manuallyAddedThumbnail.jpg.app1 3KB
manuallyAddedThumbnail.jpg.app1 3KB
windowsXpFields.jpg.app1 2KB
windowsXpFields.jpg.app1 2KB
crash01.jpg.app1 538B
crash01.jpg.app1 538B
iccDataInvalid1.jpg.app2 31KB
iccDataInvalid1.jpg.app2 31KB
windowsXpFields.jpg.app2 3KB
withExifAndIptc.jpg.app2 3KB
windowsXpFields.jpg.app2 3KB
withExifAndIptc.jpg.app2 3KB
withXmpAndIptc.jpg.app2 574B
withXmpAndIptc.jpg.app2 574B
adobeJpeg1.jpg.app2 546B
adobeJpeg1.jpg.app2 546B
adobeJpeg1.jpg.appd 17KB
adobeJpeg1.jpg.appd 17KB
withXmpAndIptc.jpg.appd 10KB
withXmpAndIptc.jpg.appd 10KB
withExifAndIptc.jpg.appd 5KB
withExifAndIptc.jpg.appd 5KB
nikonMakernoteType1.jpg.appd 5KB
nikonMakernoteType1.jpg.appd 5KB
windowsXpFields.jpg.appd 3KB
windowsXpFields.jpg.appd 3KB
withExif.jpg.appd 898B
withExif.jpg.appd 898B
nikonMakernoteType2b.jpg.appd 876B
nikonMakernoteType2b.jpg.appd 876B
iptc1.jpg.appd 250B
iptc1.jpg.appd 250B
iptc2-photoshop6.jpg.appd 248B
iptc2-photoshop6.jpg.appd 248B
nikonMakernoteType1.jpg.appe 12B
adobeJpeg1.jpg.appe 12B
windowsXpFields.jpg.appe 12B
withExifAndIptc.jpg.appe 12B
nikonMakernoteType1.jpg.appe 12B
adobeJpeg1.jpg.appe 12B
windowsXpFields.jpg.appe 12B
withExifAndIptc.jpg.appe 12B
DSC05338.ARW 23.89MB
AUTHORS 717B
256color-10x10.bmp 1KB
256color-10x10.bmp 1KB
24bpp-10x10.bmp 374B
24bpp-10x10.bmp 374B
16color-10x10.bmp 198B
16color-10x10.bmp 198B
共 1666 条
- 1
- 2
- 3
- 4
- 5
- 6
- 17
资源评论
马coder
- 粉丝: 1204
- 资源: 6602
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功