BenchmarkApplication.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System.Threading.Tasks;
  4. using PlatformExtensions;
  5. namespace PlatformBenchmarks
  6. {
  7. public partial class BenchmarkApplication
  8. {
  9. #if !DATABASE
  10. [Route("/plaintext")]
  11. static string PlainText() => "Hello, World!";
  12. [Route("/json")]
  13. static JsonMessage Json() => new JsonMessage { message = "Hello, World!" };
  14. #else
  15. [Route("/db")]
  16. static Task<World> SingleQuery() => Db.GetRow();
  17. [Route("/queries/{count}")]
  18. static Task<World[]> MultipleQueries(int count) => Db.GetRows(count);
  19. [Route("/cached-worlds/{count}")]
  20. static Task<World[]> Caching(int count) => Db.GetCachedRows(count);
  21. [Route("/updates/{count}")]
  22. static Task<World[]> Updates(int count) => Db.UpdateAndGetRows(count);
  23. #endif
  24. public static RawDb Db { get; set; }
  25. }
  26. public struct JsonMessage
  27. {
  28. public string message { get; set; }
  29. }
  30. }