Advertisement
POdkovyrkinDaniil

Untitled

Dec 17th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Profiling
  8. {
  9. class Generator
  10. {
  11. public static string GenerateDeclarations()
  12. {
  13. var result = "";
  14. foreach (var constant in Constants.FieldCounts)
  15. {
  16. result += "\nstruct S" + constant.ToString() + "{";
  17. for (var j = 0; j < constant; j++)
  18. {
  19. result += "byte Value" + j.ToString() + "; ";
  20. }
  21. result += "}\n";
  22.  
  23. result += "\nclass C" + constant.ToString() + "{";
  24. for (var j = 0; j < constant; j++)
  25. {
  26. result += "byte Value" + j.ToString() + "; ";
  27. }
  28. result += "}\n";
  29. }
  30. return result;
  31. }
  32.  
  33. public static string GenerateArrayRunner()
  34. {
  35. var result = "public class ArrayRunner : IRunner\n{";
  36. foreach (var constant in Constants.FieldCounts)
  37. {
  38. result += "\nvoid PC" + constant.ToString() + "()\n{\nvar array = new C" + constant.ToString() + "[Constants.ArraySize];\nfor (int i = 0; i < Constants.ArraySize; i++) array[i] = new C" + constant.ToString() + "();\n}\nvoid PS" + constant.ToString() + "()\n{\nvar array = new S" + constant.ToString() + "[Constants.ArraySize];\n}\n";
  39. }
  40. result += "public void Call(bool isClass, int size, int count)\n{";
  41. foreach (var constant in Constants.FieldCounts)
  42. {
  43. result += "\nif (isClass && size == " + constant.ToString() + "){for (int i = 0; i < count; i++) PC" + constant.ToString() + "();\nreturn;}\nif (!isClass && size == " + constant.ToString() + ")\n{\nfor (int i = 0; i < count; i++) PS" + constant.ToString() + "();\nreturn;\n}";
  44. }
  45. result += "\nthrow new ArgumentException();}}";
  46. return result;
  47. }
  48. public static string GenerateCallRunner()
  49. {
  50. throw new NotImplementedException();
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement