特征得分

介绍 (Introduction)

I started this project after wanting to check the Windows Experience score in my current Windows 10 Pro install and realizing that the system tool for displaying the score was no longer included in the OS. However, the benchmark utility, WinSAT.exe is still present in the %windows%system32 directory. It can be run from the command line using the "formal" parameter to generate a new benchmark, which is stored as a *.xml file in the Windows\Performance\WinSAT\DataStore directory. The results can be seen reading the XML code, and there are multiple work-arounds on-line for viewing the results in Administration Tools, for example. While others have written viewers that emulate the old Windows score display, I wanted to write my own to learn how better to work with XML files generally, and as a programming exercise.

我想检查当前Windows 10 Pro安装中的Windows Experience得分并意识到用于显示得分的系统工具已不再包含在OS中之后,便开始了该项目。 但是,基准测试实用程序WinSAT.exe仍然存在于%windows%system32目录中。 可以使用“ formal”参数从命令行运行它以生成新的基准,该基准以* .xml文件的形式存储在Windows \ Performance \ WinSAT \ DataStore目录中。 可以通过阅读XML代码来查看结果,例如,可以通过多种在线解决方法在线查看管理工具中的结果。 尽管其他人编写了模仿旧Windows乐谱显示的查看器,但我还是想写自己的书,以学习如何更好地使用XML文件,以及如何进行编程。

背景 (Background)

The Windows Experience score is a built-in system benchmark that first appeared in Windows Vista. While there are many other more sophisticated benchmarking tools, it still provides a quick (1 minute or so) test of overall system components and a summary score of the PC as a whole, and is included for free with the OS. While previous version of Windows displayed this score on demand, the tool provided to view disappeared with Windows 10.

Windows Experience分数是内置的系统基准,最早出现在Windows Vista中。 尽管还有许多其他更复杂的基准测试工具,但它仍可提供对整个系统组件的快速测试(大约1分钟),以及整个PC的总体评分,并且该操作系统免费提供。 Windows的早期版本按需显示此分数,而Windows 10所提供的查看工具消失了。

使用代码 (Using the Code)

The program I came up uses a simple class to turn the contents of the *.xml datafile into a flat database that can be manipulated as a List<> object. It uses the XmlReader class to navigate along the node tree of the XML string storing each node as an "xitem" object that contains a header string (the name of the node higher in the hierarchy, if any), a name string, and a data string (which is the "value" property). Since XML nodes may also have attribute strings, these are stored in xitem as an internal List in each xitem, where each attribute also has a name and a value (using an xattribute class). The relevant data from WinSAT benchmarks is stored mainly in the Text Node type, but XmlNodeTypes such as XmlDeclaration, DocumentType, EntityReference, Comment, ProcessingInstruction, CDATA, and Comment are also stored in the database. A Last-in-First-Out stack is used to hold the names of each node which is then "popped" off when an EndElement XmlNode.Type is encountered so the hierarchical order of the document is preserved in the database. Once the XML file is parsed, it can be searched for specific target data using two methods, string GetdataValue(string header, string name) and string GetAttributeValue(string header, string name, int number). The method bool ItemContainsData(int itemnumber) is helpful when searching the List<xitem> object. In the case of the WinSAT XML files, for example, the overall System Score from the benchmark can be read as: string systemscore = GetDataValue("WinSPR","SystemScore") and the date and time when the assessment was run as: string lastupdatetext = GetAttributeValue("SystemEnvironment","ExecDateTOD",1). This methodology should work for any XML file storing data, recognizing that the arrangement of names and values is not standardized so it would have to be customized for any given application after reading the XML source as text file to locate the data you want to work with. The program displays the benchmark results culled from the XML in a form similar to that in older versions of Windows. The "Rerun Benchmark" button spawns a new process running WinSAT.exe from the command line to generate a new benchmark *.xml file. When the process completes, a background FileSystemWatcher monitoring the DataStore directory alerts the main form, which updates. It also collects a list of all older assessments in the DataStore directory so these can be reviewed and compared, if desired.

我提出的程序使用一个简单的类将* .xml数据文件的内容转换为可作为List<>对象操作的平面数据库。 它使用XmlReader类在XML字符串的节点树中导航,将每个节点存储为“ xitem ”对象,该对象包含标头字符串(层次结构中较高节点的名称,如果有的话),名称字符串和数据字符串(这是“ value ”属性)。 由于XML节点也可能具有属性字符串,因此将它们存储在xitem作为每个xitem的内部List ,其中每个属性还具有名称和值(使用xattribute class )。 WinSAT基准测试中的相关数据主要存储在文本节点类型中,但是XmlNodeTypes例如XmlDeclarationDocumentTypeEntityReferenceCommentProcessingInstructionCDATAComment也存储在数据库中。 使用EndElement XmlNode.Type先出堆栈保存每个节点的名称,然后在遇到EndElement XmlNode.Type时“弹出”每个节点的名称,以便将文档的层次结构顺序保留在数据库中。 解析XML文件后,可以使用两种方法在string搜索特定的目标数据,即string GetdataValue(string header, string name)string GetAttributeValue(string header, string name, int number) 。 搜索List<xitem>对象时,方法bool ItemContainsData(int itemnumber)很有用。 例如,在WinSAT XML文件的情况下,基准测试的总体系统得分可以读取为: string systemscore = GetDataValue("WinSPR","SystemScore")以及运行评估的datetime为: string lastupdatetext = GetAttributeValue("SystemEnvironment","ExecDateTOD",1) 。 这种方法论应该适用于任何存储数据的XML文件,因为认识到名称和值的排列方式不是标准化的,因此在将XML源作为文本文件读取以查找要使用的数据后,必须为任何给定的应用程序自定义它。 该程序以类似于Windows早期版本的形式显示从XML收集的基准测试结果。 “ 重新运行基准 ”按钮从命令行生成一个运行WinSAT.exe的新进程,以生成新的基准* .xml文件。 该过程完成后,监视DataStore目录的后台FileSystemWatcher警告主窗体,该窗体将更新。 它还会在DataStore目录中收集所有较早评估的列表,以便可以根据需要进行检查和比较。

These are the two classes used to store XML Nodes in a List<> object:

这是用于将XML节点存储在List<>对象中的两个类:

/// <summary>
/// XATTRIBUTE CLASS
/// Stores an xml attribute
/// </summary>[Serializable]
public class xattribute
{public string aname;public string avalue;
}
/// <summary>
/// XITEM CLASS
/// Stores xml node
/// </summary>[Serializable]
public class xitem
{public string header;public string name;public List<xattribute> attributes = new List<xattribute>();public string data;
}

This method uses the XmlReader Class to navigate the nodes of the benchmark XML source file and convert them into a List of xitem objects.

此方法使用XmlReader类导航基准XML源文件的节点,并将其转换为xitem对象的List

// GETXMLFROM FILE()
// Fills in itemlist "XI" from specified fileprivate void GetXmlFromFile(string filename){XmlReaderSettings settings = new XmlReaderSettings();settings.DtdProcessing = DtdProcessing.Parse;XmlReader reader = XmlReader.Create(filename, settings);XI.Clear();int count = 0;int x = 0;bool AddToXi = false;while (reader.Read()){xitem dataitem = new xitem();AddToXi = false;switch (reader.NodeType){case XmlNodeType.Element:dataitem.name = reader.Name.ToString();if (!HeaderStack.IsEmpty()){dataitem.header = HeaderStack.GetLastItem();   // current headerHeaderStack.Push(dataitem.name); // header next subnode// is this item's name}else{dataitem.header = "";HeaderStack.Push(dataitem.name); // header next subnode// is this item's name}dataitem.data = reader.Value;        // prior code data="";AddToXi = true;break;case XmlNodeType.Text:XI[XI.Count - 1].data = reader.Value.ToString();break;case XmlNodeType.CDATA:XI[XI.Count - 1].data = reader.Value.ToString();break;case XmlNodeType.ProcessingInstruction:dataitem.name = reader.Name;dataitem.data = reader.Value;dataitem.header = "PROCESSING INSTRUCTION";AddToXi = true;break;case XmlNodeType.Comment:dataitem.name = reader.Name;dataitem.data = reader.Value;dataitem.header = "COMMENT";AddToXi = true;break;case XmlNodeType.XmlDeclaration:dataitem.header = "XML DECLARATION";dataitem.name = reader.Name;dataitem.data = reader.Value;AddToXi = true;//sb.Append("<?xml version='1.0'?>");break;case XmlNodeType.Document:break;case XmlNodeType.DocumentType:dataitem.name = "<!DOCTYPE " + reader.Name + " " + reader.Value;dataitem.header = "";dataitem.data = reader.Value.ToString();AddToXi = true;break;case XmlNodeType.EntityReference:dataitem.name = "ENTITY REFERENCE";dataitem.data = reader.Name.ToString();dataitem.header = "";AddToXi = true;break;case XmlNodeType.EndElement:HeaderStack.Pop();break;}if (reader.HasAttributes){for (x = 0; x < reader.AttributeCount; x++){reader.MoveToAttribute(x);xattribute xa = new xattribute();xa.aname = reader.Name;xa.avalue = reader.Value;dataitem.attributes.Add(xa);}}if (AddToXi){XI.Add(dataitem);count++;}}}

Once in the List of xitems, it can be searched for specific information to be displayed using:

一旦进入xitem List ,就可以使用以下命令搜索要显示的特定信息:

// GET DATA VALUE FROM XML NODE IN LISTprivate string GetDataValue(string header, string name){string result = "";int x = 0;for (x = 0; x < XI.Count; x++){if (XI[x].header == header && XI[x].name == name){result = XI[x].data;}}return result;}

and:

和:

// GET ATTRIBUTE FROM XML NODE IN LISTprivate string GetAttributeValue(string header, string name, int number){string result = "";int x = 0;for (x = 0; x < XI.Count; x++){if (XI[x].header == header && XI[x].name == name){if (XI[x].attributes.Count >= number){result = XI[x].attributes[number - 1].avalue;break;}}}return result;}

兴趣点 (Points of Interest)

系统文件重定向处理 (System File Redirection Handling)

Writing this code was my first experience with the Windows 32/64 File Redirection issue. If you are not aware of this process, you will be confounded by the inability of reading or running a system file, such as WinSAT.exe in the system32 directory programmatically even though you can see the file when you browse the folder with Explorer. This occurs because, in general, the system files in %system32% in a 64 bit install of Windows 10 are in fact 64 bit versions of 32 bit files with the same names as those in a 32 bit Install. If you are running a 32 bit application in your 64 bit Windows 10 environment, the OS assumes when you try to access the %system32% directory that you really want the 32 bit version of whatever system EXE or DLL you are seeking, and "redirects" your program to the SysWow64 folder instead, where the 32 bit versions of the OS system files have been moved in 64 bit Windows. However, WinSAT.exe exists in only one location, the original %system32% directory. For some reason, it is not duplicated in SysWow64. Hence, attempting to access it with File.Exists("C:\\Windows\\system32\\WinSAT.exe") or Process.StartInfo will fail. Windows 10 running in 64 bit mode does provide a "virtual" folder, "sysnative" which you can use as a substitute for "system32" to access the old 32 bit system file folder, but I found this confusing to work with.

编写此代码是我第一次接触Windows 32/64文件重定向问题。 如果您不知道此过程,则无法以编程方式读取或运行系统文件(例如, system32目录中的WinSAT.exe) ,即使您使用资源管理器浏览该文件夹时仍能看到该文件,也会感到困惑。 发生这种情况的原因通常是Windows 10的64位安装中的%system32%中的系统文件实际上是32位文件的64位版本,其名称与32位安装中的名称相同。 如果您在64位Windows 10环境中运行32位应用程序,则操作系统会在您尝试访问%system32%目录时假定您确实要查找要查找的任何系统EXE或DLL的32位版本,然后“重定向”,而是将程序转移到SysWow64文件夹中,其中32位版本的OS系统文件已在64位Windows中移动。 但是, WinSAT.exe仅存在于一个位置(原始%system32%目录)中。 由于某些原因,它不会在SysWow64复制。 因此,尝试使用File.Exists("C:\\Windows\\system32\\WinSAT.exe")Process.StartInfo访问它将会失败。 在64位模式下运行的Windows 10确实提供了一个“ 虚拟 ”文件夹“ sysnative ”,您可以用它代替“ system32 ”来访问旧的32位系统文件文件夹,但是我发现使用此文件夹令人困惑。

While you could simply copy WinSAT.exe to another non-redirected folder, the simplest way to access it in whatever normal folder it occupies, depending on which version of Windows 10 is running, is to turn off folder redirection if the current environment is 64 bit windows, using this code fragment to determine which version is running:

尽管您可以简单地将WinSAT.exe复制到另一个非重定向文件夹,但在当前占用的普通文件夹中访问它的最简单方法是关闭文件夹重定向(如果当前环境为64,具体取决于运行的是Windows 10的版本)。位窗口,使用此代码片段确定正在运行的版本:

private static bool is64BitProcess = (IntPtr.Size == 8); // true if running as a 64bit process.
private static bool is64BitOperatingSystem = is64BitProcess || InternalCheckIsWow64();           // true if current Windows OS is 64bit, // used for redirection handling// Detect 32 or 64 bit OS
// Credits:
// MICROSOFT: Raymond Chen
// http://blogs.msdn.com/oldnewthing/archive/2005/02/01/364563.aspx[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)][return: MarshalAs(UnmanagedType.Bool)]private static extern bool IsWow64Process([In] IntPtr hProcess,[Out] out bool wow64Process);private static bool InternalCheckIsWow64(){if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) ||Environment.OSVersion.Version.Major >= 6){using (Process p = Process.GetCurrentProcess()){bool retVal;if (!IsWow64Process(p.Handle, out retVal)){return false;}return retVal;}}else{return false;}}// Handle Folder Redirection in Windows 64// Credits:// http://tcamilli.blogspot.com/2005/07/disabling-wow64-file-system.html// https://stackoverflow.com/questions/29149512/// process-start-for-system32-applications-the-system-cannot-find-the-file-specif/// <summary>/// Use to enable and disable file redirection in Win 64/// </summary>public class Wow64Interop{[DllImport("Kernel32.Dll", EntryPoint = "Wow64EnableWow64FsRedirection")]public static extern bool EnableWow64FSRedirection(bool enable);}

and use this path to the WinSAT.exe file:

并使用以下路径访问WinSAT.exe文件:

public static string ExePathFor64BitApplication = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), @"system32\winsat.exe");

Then launch WinSAT as a separate process to create the benchmark xml:

然后启动WinSAT作为单独的过程来创建基准xml

Process n = new Process();n.StartInfo.FileName = ExePathFor64BitApplication;if (is64BitOperatingSystem){Wow64Interop.EnableWow64FSRedirection(false);n.Start();ID = n.Id;Wow64Interop.EnableWow64FSRedirection(true);}else{n.Start();ID = n.Id;ProcessHandle = n.Handle;}

监视数据存储文件夹中新的Winsat创建的XML文件 (Watching the Datastore Folder for a New Winsat-Created XML File)

A final programming point-of-interest I encountered was how to determine if WinSAT.exe had finished running and created a new benchmark file, so I could refresh the application window with the new data automatically. My solution was to create a wrapper class encapsulating a FileSystemWatcher object, that could in turn be instantiated in a BackGroundWorker DoWork() method which exits when the FileSystemWatcher.Changed event fires. The BackGroundWorker.Completed method then refreshes the form with the new benchmark.

我遇到的最后一个编程兴趣点是如何确定WinSAT.exe是否已完成运行并创建了新的基准文件,因此我可以自动使用新数据刷新应用程序窗口。 我的解决方案是创建一个包装FileSystemWatcher对象的包装器类,该包装类又可以在BackGroundWorker DoWork()方法中实例化,该方法在FileSystemWatcher.Changed事件触发时退出。 然后, BackGroundWorker.Completed方法使用新的基准刷新表单。

    /// Call from a Background Worker DoWork() instance with Path and File extension filter./// Watches for File Create/// </summary>/// <param name="Path">Used for Folder to watch.</param>/// <param name="Filter">Used for file extension to watch for as in *.xml.</param>/// <returns>Nothing, DoWork uses() Completed property to terminate</returns>public class FSWatcher{// Constructorpublic FSWatcher(string Path,string Filter){watcher = new FileSystemWatcher(Path,Filter);watcher.Created += watcher_changed;watcher.NotifyFilter = NotifyFilters.LastAccess| NotifyFilters.LastWrite| NotifyFilters.FileName| NotifyFilters.DirectoryName;}// Destructor~FSWatcher(){watcher.Dispose();}//Public status accessorpublic bool Completed{get{return completed;}}// Public start methodpublic void Start(){completed = false;watcher_start();}private FileSystemWatcher watcher;private void watcher_changed(object sendwer, FileSystemEventArgs e){watcher.EnableRaisingEvents = false;completed = true;}private void watcher_start(){watcher.EnableRaisingEvents = true;}private bool completed = false;}// BackgroundWorker DoWork()private void bwDoWork(object sender, DoWorkEventArgs e){BackgroundWorker worker = sender as BackgroundWorker;FSWatcher FSW = new FSWatcher(DataStorePath, "*.*");        FSW.Start();while (!FSW.Completed){// Wait for completion}            }// BackgroundWorker completedprivate void bwCompleted(object sender, RunWorkerCompletedEventArgs e){            Thread.Sleep(3000);            // Ensure file creation is completed // and file is unlockedPopulateDataFileList();PopulateAssessmentFileNames();if (AssessmentFileNames.Count > 0){ParseXml(AssessmentFileNames[AssessmentFileNames.Count - 1]);}btnGetBenchMark.Enabled = true;}

摘要 (Summary)

In the process of re-creating the Windows Experience tool so I could more easily check the system benchmark for my home built PC, I learned more about the XML file structure which is commonly used to store data for program and hardware installations. Having a simple way to load and search these files can be useful, recognizing that the way data is stored within nodes varies with each creating application so one has to read the XML as a text file first to find out where the information you are seeking is located. Once found, items such as the test results from WinSAT can be easily displayed and manipulated.

在重新创建Windows Experience工具的过程中,我可以更轻松地检查家用PC的系统基准,我了解了有关XML文件结构的更多信息,该XML文件结构通常用于存储程序和硬件安装的数据。 认识到节点中数据的存储方式随每个创建的应用程序而变化,因此有一种简单的方式来加载和搜索这些文件可能会很有用,因此必须首先将XML作为文本文件读取,以查找所需的信息在哪里。位于。 一旦找到,诸如WinSAT的测试结果之类的项目就可以轻松显示和操作。

翻译自: https://www.codeproject.com/Articles/5250414/Windows-Experience-Score-For-Windows-10

特征得分

特征得分_Windows 10的Windows体验得分相关推荐

  1. windows商店_Windows 10商店迎来重大改变,PC平台游戏计划公布

    UWP应用是微软推出Windows 10之后寄予厚望的全新格式应用,UWP最大的特点是可以跨平台使用,无论在手机.平板还是PC上,都可以自适应屏幕大小与操作方式,非常便捷. 不过自从Windows P ...

  2. Windows 10如何进行“Windows体验指数评估”?

    #精彩回顾:[分享]盘点那些有趣又实用的cmd命令~_CharlesChen_09的博客-CSDN博客# 想知道你的电脑性能如何?可能有人会告诉你:运行一下"Windows体验指数评估&qu ...

  3. 计算机硬件评分系统,win7系统使用自带windows体验指数给计算机硬件评分的操作方法...

    很多小伙伴都遇到过对win7系统使用自带windows体验指数给计算机硬件评分进行设置的困惑吧,一些朋友看过网上对win7系统使用自带windows体验指数给计算机硬件评分设置的零散处理方法,并没有完 ...

  4. 获取版本号_Windows 10 2004迎来KB4577063更新 版本号升至19041.546

    微软刚刚向 Windows 10 2004 用户推送了 KB4577063 累积更新,安装后系统版本号将升至 19041.546 .作为一个可选更新,用户需要通过 Windows Update 手动检 ...

  5. 不止 Windows 10!Windows 7/8 也能免费升级到 Windows 11

    起初,微软宣布为 Windows 7.Windows 8 和 Windows 8.1 用户提供的 Windows 10 免费升级于 2016 年结束. Windows 11 免费升级 近日,微软表示将 ...

  6. adb interface找不到驱动程序_Windows 10现支持更多设备的驱动程序更新

    8 月份的时候,微软在 Windows 10 的 Windows Update 面板中启用了一个类似 Windows 7 的"可选更新"项目.在版本修订前,用户还是可以在设备管理器 ...

  7. sql查询大于平均得分的球员的名字和得分,并追加显示平均得分的列

    首先,查询大于平均得分的球员的名字和得分 突发奇想,想在查询结果后将平局得分也加上去,便于对比. 开始以为left join ,with as什么的实现,后来发现并不需要 1.分析,平均得分是固定的, ...

  8. Windows 11 即将问世 | Windows 10 和 Windows 11 该如何抉择

    全新 Windows 11 将于 10 月 5 日上市,微软宣布了运行新操作系统所需的最低配置要求.了解这一点后,你就可以查看你的 Windows10 系统是否能够完成升级 Windows 11 即将 ...

  9. windows server 2008 R2、windows 10、windows server 2012 R2安装windows media player

    **windows server 2008 R2.windows 10.windows server 2012 R2安装windows media player** windows 10: 1.打开控 ...

最新文章

  1. 使用 SQL Server Mobile 创建移动应用程序
  2. oracle怎么以时间排序,oracle指定数据排序在前面怎么处理
  3. java模拟记事本的一些功能
  4. Java初学者需掌握的30个概念
  5. 运动会计算机系,秋季运动会计算机系总结计划 (12页)-原创力文档
  6. zen of python什么意思_Zen of Python
  7. C. mathematican 的二进制
  8. 队列服务(Queue)
  9. 使用vgg19进行微表情分类
  10. 微信小程序│ 游戏开发 │连连看游戏
  11. 非常时期的囤货手册,建议查看收藏
  12. Apollo星火计划学习笔记——第八讲Apollo控制模块解析与实践1
  13. 微信Android如何实现计步数,微信运动步数是怎样计算的?终于有人研究出来了......
  14. pdf to word android,PDF to Word Converter
  15. 书籍 -- 《高性能MySQL》持续更新中(四)
  16. 深夜磨刀,Linux Graphics Stack 概述 | Linux 驱动
  17. hack the box 注册邀请码的获取
  18. 【AI语音】华为EC6110M、Q21AQ、Q21C部分EC6110T、EC6110U_海思3798MV310_通刷_卡刷固件
  19. python增强对比度_OpenCV-Python-(4)-对比度增强
  20. Java+MySQL 基于ssm的停车位短租租赁管理系统程序#毕业设计

热门文章

  1. 虚拟服务器销售犯罪吗,卖云服务器犯法吗
  2. python实现冒泡排序算法
  3. 湖南大学21夏训练四6.数塔
  4. 记录 Js 二维数组的排序
  5. 敏感信息收集常用工具
  6. 7_将输入单词译成密码
  7. offsetWidth、offsetHeight、clientHeight、clientWidth、scrollHeight、scrollWidth详细对比
  8. 大牛传授Web前端工程师的强者之路之从业经验
  9. uploadify 报错jquery.uploadify.min.js:16 Uncaught TypeError: Cannot read property 'queueData' of undef
  10. hive select报错 Unable to determine if hdfs