<commit_before>function Get-DbaTopResourceUsage {
	<# 
	.SYNOPSIS 
		Returns the top 20 resource consumers for cached queries based on four different metrics: duration, frequency, IO, and CPU.

	.DESCRIPTION
		Returns the top 20 resource consumers for cached queries based on four different metrics: duration, frequency, IO, and CPU.
	
		This command is based off of queries provided by <NAME> at http://michaeljswart.com/go/Top20
	
		Per Michael: "I've posted queries like this before, and others have written many other versions of this query. All these queries are based on sys.dm_exec_query_stats."
	
	.PARAMETER SqlInstance
		Allows you to specify a comma separated list of servers to query.

	.PARAMETER SqlCredential
		Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted. To use:
		$cred = Get-Credential, this pass this $cred to the param. 

		Windows Authentication will be used if DestinationSqlCredential is not specified. To connect as a different Windows user, run PowerShell as that user.	

	.PARAMETER Database
		The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.
	
	.PARAMETER ExcludeDatabase
		The database(s) to exclude - this list is auto-populated from the server

	.PARAMETER ExcludeSystem
		This will exclude system objects like replication procedures from being returned.
	
	.PARAMETER Type
		By default, all Types run but you can specify one or more of the following: Duration, Frequency, IO, or CPU

	.PARAMETER Limit
		By default, these query the Top 20 worst offenders (though more than 20 results can be returend if each of the top 20 have more than 1 subsequent result)
	
	.PARAMETER Silent 
		Use this switch to disable any kind of verbose messages (this is required)

	.NOTES 
		Tags: Query, Performance
		Website: https://dbatools.io
		Copyright: (C) <NAME>, <EMAIL>
		License: GNU GPL v3 https://opensource.org/licenses/GPL-3.0

	.LINK 
		https://dbatools.io/Get-DbaTopResourceUsage

	.EXAMPLE   
		Get-DbaTopResourceUsage -SqlInstance sql2008, sql2012
		Return the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and sql2012

	.EXAMPLE   
		Get-DbaTopResourceUsage -SqlInstance sql2008 -Type Duration, Frequency -Database TestDB
		Return the highest usage by duration (top 20) and frequency (top 20) for the TestDB on sql2008

	.EXAMPLE   
		Get-DbaTopResourceUsage -SqlInstance sql2016 -Limit 30
		Return the highest usage by duration (top 30) and frequency (top 30) for the TestDB on sql2016<commit_msg>Added an example<commit_after>function Get-DbaTopResourceUsage {
	<# 
	.SYNOPSIS 
		Returns the top 20 resource consumers for cached queries based on four different metrics: duration, frequency, IO, and CPU.

	.DESCRIPTION
		Returns the top 20 resource consumers for cached queries based on four different metrics: duration, frequency, IO, and CPU.
	
		This command is based off of queries provided by <NAME> at http://michaeljswart.com/go/Top20
	
		Per Michael: "I've posted queries like this before, and others have written many other versions of this query. All these queries are based on sys.dm_exec_query_stats."
	
	.PARAMETER SqlInstance
		Allows you to specify a comma separated list of servers to query.

	.PARAMETER SqlCredential
		Allows you to login to servers using SQL Logins as opposed to Windows Auth/Integrated/Trusted. To use:
		$cred = Get-Credential, this pass this $cred to the param. 

		Windows Authentication will be used if DestinationSqlCredential is not specified. To connect as a different Windows user, run PowerShell as that user.	

	.PARAMETER Database
		The database(s) to process - this list is auto-populated from the server. If unspecified, all databases will be processed.
	
	.PARAMETER ExcludeDatabase
		The database(s) to exclude - this list is auto-populated from the server

	.PARAMETER ExcludeSystem
		This will exclude system objects like replication procedures from being returned.
	
	.PARAMETER Type
		By default, all Types run but you can specify one or more of the following: Duration, Frequency, IO, or CPU

	.PARAMETER Limit
		By default, these query the Top 20 worst offenders (though more than 20 results can be returend if each of the top 20 have more than 1 subsequent result)
	
	.PARAMETER Silent 
		Use this switch to disable any kind of verbose messages (this is required)

	.NOTES 
		Tags: Query, Performance
		Website: https://dbatools.io
		Copyright: (C) <NAME>, <EMAIL>
		License: GNU GPL v3 https://opensource.org/licenses/GPL-3.0

	.LINK 
		https://dbatools.io/Get-DbaTopResourceUsage

	.EXAMPLE   
		Get-DbaTopResourceUsage -SqlInstance sql2008, sql2012
		Return the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and sql2012

	.EXAMPLE   
		Get-DbaTopResourceUsage -SqlInstance sql2008 -Type Duration, Frequency -Database TestDB
		Return the highest usage by duration (top 20) and frequency (top 20) for the TestDB on sql2008

	.EXAMPLE   
		Get-DbaTopResourceUsage -SqlInstance sql2016 -Limit 30
		Return the highest usage by duration (top 30) and frequency (top 30) for the TestDB on sql2016
	
	.EXAMPLE
	Get-DbaTopResourceUsage -SqlInstance sql2008, sql2012 -ExcludeSystem
		Return the 80 (20 x 4 types) top usage results by duration, frequency, IO, and CPU servers for servers sql2008 and sql2012 without any System Objects

{'fraction_non_alphanumeric': 0.05249632892804699, 'fraction_numerical': 0.026982378854625552, 'mean_word_length': 3.98992673992674, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2961527', 'n_tokens_mistral': 1690, 'n_tokens_neox': 1460, 'n_words': 731}