Last active
October 16, 2019 00:28
-
-
Save VinixGonzalez/fa761d236f485c5fbcab5fc164ef5b8f to your computer and use it in GitHub Desktop.
Stopwatch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Stopwatch01 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Instancia um objeto do tipo Stopwatch | |
Stopwatch watch = new Stopwatch(); | |
// Conexão com o banco de dados de teste | |
using (ApplicationContext db = new ApplicationContext()) | |
{ | |
// Inicia o cronômetro com o método Start() | |
watch.Start(); | |
// Busca todos os registros da tabela de testes | |
var testes = db.Teste.AsNoTracking().ToList(); | |
// Para o cronômetro | |
watch.Stop(); | |
// Output do total de registros | |
Console.WriteLine($"Total: {testes.Count} registros."); | |
} | |
// Através da propriedade .Elapsed.TotalSeconds, obtemos o tempo total em segundos | |
Console.WriteLine($"{watch.Elapsed.TotalSeconds} segundos."); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment