GoogleGetTimePrintService.cs 895 B

12345678910111213141516171819202122232425262728293031
  1. using Microsoft.Extensions.Logging;
  2. using RestSharp;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using ZstdSharp.Unsafe;
  10. namespace EVCB_OCPP.WSServer.Service
  11. {
  12. public class GoogleGetTimePrintService
  13. {
  14. private readonly ILogger<GoogleGetTimePrintService> logger;
  15. public GoogleGetTimePrintService(ILogger<GoogleGetTimePrintService> logger)
  16. {
  17. this.logger = logger;
  18. }
  19. public async Task Print()
  20. {
  21. var client = new RestClient("http://www.google.com");
  22. var stopWatch = Stopwatch.StartNew();
  23. await client.ExecuteAsync(new RestRequest("",method: Method.Get));
  24. stopWatch.Stop();
  25. logger.LogInformation($"Google Get Cost {stopWatch.ElapsedMilliseconds}ms");
  26. }
  27. }
  28. }