GoogleGetTimePrintService.cs 755 B

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