{"id":87199,"date":"2020-05-20T17:16:44","date_gmt":"2020-05-20T17:16:44","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?p=87199"},"modified":"2022-04-24T16:14:43","modified_gmt":"2022-04-24T16:14:43","slug":"tackle-big-o-notation-in-net-core","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/development\/dotnet-development\/tackle-big-o-notation-in-net-core\/","title":{"rendered":"Tackle Big-O Notation in .NET Core"},"content":{"rendered":"<p>Performance sensitive code is often overlooked in business apps. This is because high-performance code might not affect outcomes. Concerns with execution times are ignorable if the code finishes in a reasonable time. Apps either meet expectations or not, and performance issues can go undetected. Devs, for the most part, care about business outcomes and performance is the outlier. When response times cross an arbitrary line, everything flips to less than desirable or unacceptable.<\/p>\n<p>Luckily, the Big-O notation attempts to approach this problem in a general way. This focuses both on outcomes and the algorithm. Big-O notation attempts to conceptualize algorithm complexity without laborious performance tuning.<\/p>\n<p>In this take, I\u2019ll delve into Big-O notation and how to apply this in .NET. I\u2019ll begin with theory found in intro to computer programing courses. Then, dive into examples based on real-world code. In the end, this guides through the creative process of writing algorithms that use sound theory.<\/p>\n<p>I\u2019ll stick with proven tools such as <a href=\"https:\/\/dotnet.microsoft.com\/download\/dotnet-core\/3.1\">.NET Core 3.1.100<\/a>, the recommended LTS version for now. Code samples can run in the latest version of Visual Studio 2019. I\u2019ll add <code>BenchmarkDotNet<\/code> to the project to verify execution times. This makes undetectable performance issues visible. You can download the sample code from <a href=\"https:\/\/github.com\/beautifulcoder\/TackleBigONetCore\">GitHub<\/a>.<\/p>\n<p>Feel free to follow along, to fire up a new project with the CLI do:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">dotnet new console<\/pre>\n<p>Be sure to do this inside of a project folder such as <em>TackleBigONetCore<\/em>. This same step is possible in Visual Studio. Because I do not wish to put you through a click hunt, I\u2019ll stick to the CLI.<\/p>\n<p>Then, be sure to add the benchmark tool:<\/p>\n<pre class=\"lang:ps theme:powershell-ise\">dotnet add package BenchmarkDotNet --version 0.12.0<\/pre>\n<p>Before I lay down a single line of code, it is best to start with theory.<\/p>\n<h2>What Is Big-O Notation?<\/h2>\n<p>The Big-O notation measures the worst-case complexity of an algorithm. The algorithm works on data input of any size. For a given <em>n<\/em>, it answers the question: \u201cWhat happens as n approaches infinity?\u201d This helps to analyze the effectiveness of an algorithm which can be measured in time and space. Think of time as the execution time, and space as the input dataset size which consumes memory.<\/p>\n<p>The algorithmic analysis gets summed up using Big-O notation, for example, O(1) for constant time. There are three main ways to do an analysis:<\/p>\n<ul>\n<li>O(1): For <em>constant time<\/em> because it does not change based on input space<\/li>\n<li>O(n): For <em>linear time<\/em> because it assumes n operations in the worst-case scenario<\/li>\n<li>O(n<sup>2<\/sup>): For <em>quadratic time<\/em> which shows exponential time degradation in the worst-case scenario<\/li>\n<li>O(n<sup>3<\/sup>): For <em>cubic time<\/em>, like O(n<sup>2<\/sup>) with exponentially greater time complexity<\/li>\n<\/ul>\n<p>I\u2019ll come back to each one as code samples get fleshed out. For now, think of algorithm complexity as a function like f(n). Input size n represents the number of inputs, f(n)<sub>time<\/sub> represents the time it takes, and f(n)<sub>space<\/sub> shows memory usage. Big-O notation comes with rules to help programmers analyze f(n). In academia, there are a lot of rules one might encounter, but I\u2019ll focus on the most relevant:<\/p>\n<ul>\n<li><em>Coefficient rule<\/em>: For any constant k &gt; 0, if kf(n) then the result is O(g(n)). This rule eliminates coefficients that multiply results from input size. This is because as n approaches infinity, coefficients become negligible.<\/li>\n<li><em>Sum rule<\/em>: If f(n) is O(h(n)), and g(n) is O(p(n)), then f(n) + g(n) is O(h(n) + p(n)). In practice the sum rule adds up two algorithms that are similar in time and space. For example, f(n) + f(n) can be 2f(n) from which applies the coefficient rule.<\/li>\n<li><em>Product rule<\/em>: If f(n) is O(h(n)), and g(n) is O(p(n)), then f(n)g(n) is O(h(n)p(n)). For algorithms similar in time and space, the product rule may result in O(n) = n<sup>2<\/sup>. For example, nested loops that multiply which results in quadratic time.<\/li>\n<\/ul>\n<p>The following shows common Big-O notations from an algorithmic analysis:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"481\" height=\"289\" class=\"wp-image-87200\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/word-image-19.png\" \/><\/p>\n<p>I recommend committing these complexities to memory in your mind\u2019s eye. As I venture through each Big-O complexity, keep this chart in mind. This helps to visualize implications as time and space exponentiate with each complexity.<\/p>\n<p>With all this Big-O theory out of the way, time to put this to good use.<\/p>\n<h2>Lab Rats<\/h2>\n<p>For this project, I\u2019ll create a contrived use case of lab rats racing three at a time in several mazes. The goal is to imagine a data model useful for algorithmic analysis. Each Big-O complexity corresponds with each dataset.<\/p>\n<p>This can go anywhere in the project. Because the emphasis is on benchmark analysis, I\u2019ll put this inside a <em>BigOBenchmarks <\/em>class.<\/p>\n<p>First, create a maze that has lab rats going three at a time:<\/p>\n<pre class=\"lang:c# theme:vs2012 \">class Maze\r\n{\r\n  public int MazeNumber { get; set; }\r\n  public Difficulty Difficulty { get; set; }\r\n  public int LabRat1 { get; set; }\r\n  public int LabRat2 { get; set; }\r\n  public int LabRat3 { get; set; }\r\n}\r\n\r\nenum Difficulty\r\n{\r\n  Easy,\r\n  Medium,\r\n  Hard\r\n}\r\n<\/pre>\n<p><span style=\"display: inline !important; float: none; background-color: #ffffff; color: #333333; cursor: text; font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;\">Now for many lab rats in each maze:<\/span><\/p>\n<pre class=\"theme:vs2012 lang:c# decode:true \">class LabRat \r\n{ \r\n   public int TrackingId { get; set; } \r\n   public Color Color { get; set; } \r\n} \r\nenum Color \r\n{ \r\n    Black, \r\n    White, \r\n    Gray \r\n}<\/pre>\n<p>Lastly, this encapsulates race data:<\/p>\n<pre class=\"lang:c# theme:vs2012\">class Race\r\n{\r\n  public int MazeNumber { get; set; }\r\n  public int Participant { get; set; }\r\n  public FinishTime FinishTime { get; set; }\r\n}\r\n\r\nenum FinishTime\r\n{\r\n  Fast,\r\n  Average,\r\n  Slow\r\n}<\/pre>\n<p>This completes the domain, there are many mazes, with many lab rats in groups of three, with many races. The rest of the <em>BigOBenchmarks<\/em> class looks like this:<\/p>\n<pre class=\"lang:c# theme:vs2012\">public class BigOBenchmarks\r\n{\r\n  private const int N = 999;\r\n\r\n  private readonly IList&lt;LabRat&gt; labRats;\r\n  private readonly IList&lt;Maze&gt; mazes;\r\n  private readonly IList&lt;Race&gt; races;\r\n\r\n  public BigOBenchmarks()\r\n  {\r\n  }\r\n\r\n  [Benchmark]\r\n  public int DummyBenchmark()\r\n  {\r\n    return 0;\r\n  }\r\n}<\/pre>\n<p>Leave the constructor empty for now, as this is where you initialize benchmark data. I\u2019ll come back to each benchmark method. For now, be sure to return a value. This way the compiler does not optimize the whole benchmark method out. Methods decorated with <code>Benchmark<\/code> are part of the benchmark result. The <code>Benchmark<\/code> attribute is in this namespace:<\/p>\n<pre class=\"lang:c# theme:vs2012\">using BenchmarkDotNet.Attributes;<\/pre>\n<p>For this analysis, I\u2019m keeping data input size N set to about a thousand. Because lab rats go three at a time, this leaves around three hundred mazes.<\/p>\n<p>To flesh out <em>BenchmarkDotNet<\/em> so that benchmarks execute, crack open <em>Program<\/em> in the console project and add this:<\/p>\n<pre class=\"lang:c# theme:vs2012\">BenchmarkRunner.Run&lt;BigOBenchmarks&gt;();<\/pre>\n<p>Be sure to include the namespace:<\/p>\n<pre class=\"lang:c# theme:vs2012\">using BenchmarkDotNet.Running;<\/pre>\n<p>The project runs with <code>dotnet watch run -c Release. BenchmarkDotNet<\/code> works on Release because Debug can be one hundred times slower. Running this in watch mode makes it to where benchmarks run at each save. Next, time to look at each Big-O complexity based on data.<\/p>\n<h2>Big-O O(n) Linear Time<\/h2>\n<p>Knock out <em>DummyBenchmark<\/em> as I\u2019ll need room for meaningful benchmarks. Say I want to pluck a single lab rat from the dataset. Start by initializing the data in the constructor:<\/p>\n<pre class=\"lang:c# theme:vs2012\">labRats = new List&lt;LabRat&gt;(N);\r\nfor (var i = 0; i &lt; N; i++)\r\n{\r\n  labRats.Add(new LabRat\r\n  {\r\n    TrackingId = i,\r\n    Color = (Color)(i % 3)\r\n  });\r\n}<\/pre>\n<p><a id=\"post-87199-_heading=h.gjdgxs\"><\/a> Note the use of N as a constructor parameter when I initialize this list of lab rats. This sets the <em>Capacity<\/em> in the internal data structure. If the data input size is known, I recommend letting .NET know too. With the data in place, the traditional way to pluck a single item in .NET is using <code>First<\/code><strong>. <\/strong>Be sure to add <code>System.Linq<\/code> to the using statements:<\/p>\n<pre class=\"lang:c# theme:vs2012\">var result = labRats.First(d =&gt; d.TrackingId == N - 1);\r\n\r\nreturn (int)result.Color;<\/pre>\n<p>Be sure to place this inside a benchmark method to verify what\u2019s happening. To the untrained eye, this may seem like a simple operation without dings in performance. But it is O(n) or linear time complexity. This is because Big-O assumes the <em>worst-case scenario<\/em>, and this means looping through a whole dataset. In .NET, <code>First<\/code> picks the first match that exists, but Big-O must assume worst-case. In a worst-case scenario, the first match goes at the end. This frees the programmer from analysis paralysis when studying algorithms. By assuming worst-case, there is less cognitive load when thinking about algorithmic complexity.<\/p>\n<p>Benchmark results are as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87211\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/Bigo.png\" alt=\"\" width=\"858\" height=\"89\" \/><\/p>\n<p>This runs on avg for 15 microseconds given a sample size of about a thousand. The key takeaway is how this executes in microseconds. Because Big-O is either <em>exponentially<\/em> better or worse it will run in different time units. For this reason, I recommend executing one benchmark at a time for better results.<\/p>\n<h2>Big-O O(n<sup>2<\/sup>) Quadratic Time<\/h2>\n<p>This time I\u2019ll need a set of mazes, go back in the <code>BigOBenchmarks<\/code> constructor and initialize maze data:<\/p>\n<pre class=\"lang:c# theme:vs2012\">mazes = new List&lt;Maze&gt;(N \/ 3);\r\nfor (var i = 0; i &lt; N \/ 3; i++)\r\n{\r\n  mazes.Add(new Maze\r\n  {\r\n    MazeNumber = i,\r\n    Difficulty = (Difficulty)(i % 3),\r\n    LabRat1 = i,\r\n    LabRat2 = i + N \/ 3,\r\n    LabRat3 = i + N \/ 3 * 2\r\n  });\r\n}<\/pre>\n<p>Maze data is but a third of lab rat data in space complexity. As data input size approaches infinity, this difference becomes <em>negligible<\/em>. This is because both datasets share similar time and space complexities.<\/p>\n<p>Say, for example, I want to pluck a lab rat and check which maze difficulty it finished. A solution is:<\/p>\n<pre class=\"lang:c# theme:vs2012\">var result = 0;\r\n\r\nforeach (var maze in mazes)\r\n{\r\n  var rat = labRats.First(r =&gt; r.TrackingId == N - 1);\r\n\r\n  result = maze.LabRat3 == rat.TrackingId ? \r\n                   (int)maze.Difficulty : result;\r\n}\r\n\r\nreturn result;<\/pre>\n<p>Be sure to put this in a benchmark, and one takeaway is the nested loops. Because of the product rule, this makes the complexity O(n<sup>2<\/sup>). The outer loop goes through each maze, and the inner loop plucks a lab rat via iteration. Conceptually, nested loops on input data size n have a <em>multiplicative<\/em> effect. If the outer loop has n items, it permutates through all items in both loops. If, for example, there are 100 items, nested loops iterate 100&#215;100 for a grand total of 10,000.<\/p>\n<p>These are the results:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87210\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/BigO1.png\" alt=\"\" width=\"860\" height=\"89\" \/><\/p>\n<p>This time results are in milliseconds. Remember the chart I showed earlier? It shows this same exponential degradation. As complexity grows in Big-O, there are performance implications to the algorithm.<\/p>\n<p>One way to tackle Big-O complexity is with a lookup table like <code>IDictionary&lt;&gt;<\/code>. Instead of having to iterate through lab rats, it is possible to pick one. A lookup table does a one-to-one mapping with a given key. Lookup mapping has a constant time complexity regardless of input data size. This reduces complexity back down to O(n).<\/p>\n<p>Add a lookup table with a .NET dictionary to the benchmark class as a private instance variable:<\/p>\n<pre class=\"lang:c# theme:vs2012\">private readonly IDictionary&lt;int, LabRat&gt; labRatLookup;<\/pre>\n<p>Because <code>First<\/code> was doing matches against the id, the lookup table uses this as the key. Initialize the lookup dictionary in the class constructor:<\/p>\n<pre class=\"lang:c# theme:vs2012\">labRatLookup = labRats.ToDictionary(l =&gt; l.TrackingId);<\/pre>\n<p>Now, run another benchmark with this algorithm:<\/p>\n<pre class=\"lang:c# theme:vs2012 \">var result = 0;\r\n\r\nforeach (var maze in mazes)\r\n{\r\n  var rat = labRatLookup[N - 1];\r\n\r\n  result = maze.LabRat3 == rat.TrackingId ? \r\n       (int)maze.Difficulty : result;\r\n}\r\n\r\nreturn result;<\/pre>\n<p>Both solutions are identical, minus the nested loop and complexity. The lookup table uses the same id <code>First<\/code> once used. So, this does not affect the outcome of the algorithm.<\/p>\n<p>Benchmark results are now:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87208\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/Bigo3.png\" alt=\"\" width=\"855\" height=\"88\" \/><\/p>\n<h2>Big-O O(n<sup>3<\/sup>) Cubic Time<\/h2>\n<p>Welcome to the fray, algorithms of this complexity tend to choke on modest size datasets. The time complexity is higher relative to the data input size.<\/p>\n<p>In the constructor, initialize rat race data:<\/p>\n<pre class=\"lang:c# theme:vs2012\">races = new List&lt;Race&gt;(N);\r\nfor (var i = 0; i &lt; N; i++)\r\n{\r\n  races.Add(new Race\r\n  {\r\n    MazeNumber = i % (N \/ 3),\r\n    Participant = i,\r\n    FinishTime = (FinishTime)(i % 3)\r\n  });\r\n}<\/pre>\n<p>This time find race finish time by cross-referencing all other data points:<\/p>\n<pre class=\"lang:c# theme:vs2012\">var result = 0;\r\n\r\nforeach (var maze in mazes)\r\n{\r\n  foreach (var rat in labRats)\r\n  {\r\n    var race = races.Where(r =&gt; r.MazeNumber == N \/ 3 - 1).ToArray();\r\n\r\n    result = maze.MazeNumber == race[2].MazeNumber\r\n      &amp;&amp; rat.TrackingId == race[2].Participant\r\n      ? (int)race[2].FinishTime : result;\r\n  }\r\n}\r\n\r\nreturn result;<\/pre>\n<p>In .NET, <code>Where<\/code> returns any items that match the predicate. This also means looping through the entire dataset. Given the product rule with three nested loops, this spikes complexity to O(n<sup>3<\/sup>).<\/p>\n<p>Benchmarks results are as follows:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87207\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/Bigo4.png\" alt=\"\" width=\"856\" height=\"88\" \/><\/p>\n<p>Wow, this breaks the second barrier, execution times are dismal. Because customers don\u2019t like to wait, this gets into unacceptable levels. Note data input size is in the hundreds, which is not that big at all. As data input size increases, count on this getting exponentially slower.<\/p>\n<p>One way to tackle this much complexity in .NET is with <code>ILookup&lt;&gt;<\/code>. This <code>Where<\/code> throws a kink because it can return any number of items. What\u2019s good is this returns arrays of constant size because lab rats go in groups of three. This makes the algorithm 3f(n), applying the coefficient rule, this brings it to constant time.<\/p>\n<p>Declare this lookup table as a private instance variable in the class:<\/p>\n<pre class=\"lang:c# theme:vs2012\">private readonly ILookup&lt;int, Race&gt; raceLookup;<\/pre>\n<p>Then, initialize race lookup data in the constructor:<\/p>\n<pre class=\"lang:c# theme:vs2012\">raceLookup = races.ToLookup(r =&gt; r.MazeNumber, r =&gt; r);<\/pre>\n<p>This makes <code>MazeNumber<\/code> the key from which we get the array with three items. This is the same predicate found in the where clause. By preserving the where clause in the key, it keeps the outcome the same. The lab rat lookup can go in here too to further optimize complexity. Now tweak the algorithm as follows:<\/p>\n<pre class=\"lang:c# theme:vs2012\">var result = 0;\r\n\r\nforeach (var maze in mazes)\r\n{\r\n  var race = raceLookup[N \/ 3 - 1].ToArray();\r\n  var rat = labRatLookup[race[2].Participant];\r\n\r\n  result = maze.MazeNumber == race[2].MazeNumber\r\n    &amp;&amp; rat.TrackingId == race[2].Participant\r\n    ? (int)race[2].FinishTime : result;\r\n}\r\n\r\nreturn result;<\/pre>\n<p>Note there are two lookups side-by-side, one for races and one for rats. Because time and space complexities are similar, applying the sum rule, this gets a 2f(n). Big-O rules <em>combine<\/em>, so, applying the coefficient rule keeps lookups at constant time. Because this loops through mazes, the complexity is O(n).<\/p>\n<p>I want to hear a drumroll please, time to check benchmarks results:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87206\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/Bigo5.png\" alt=\"\" width=\"864\" height=\"87\" \/><\/p>\n<p>This brings execution time back down to microseconds and way within an acceptable range. Note the exponential gains from more than a second to tens of microseconds. Going from cubic time down to linear time does make an astronomical difference. For business apps, this kind of performance is \u201cgood enough.\u201d Any further optimization is likely too pedantic for the working programmer.<\/p>\n<h2>Big-O O(1) Constant Time<\/h2>\n<p>The keen reader may notice lookup tables dominate complexity gains, so why not get rid of looping? Should be interesting to see how this stacks up given the theory. Lookup tables are constant time because of this <em>one-to-one<\/em> relationship. The computer has an easier time with this because it knows where to find this in memory. When a lookup returns many items, the coefficient rule keeps complexity constant if the array is of constant size.<\/p>\n<p>To eliminate looping, what is missing is a maze lookup:<\/p>\n<pre class=\"lang:c# theme:vs2012\">private readonly IDictionary&lt;int, Maze&gt; mazeLookup;<\/pre>\n<p>Go in the constructor and add:<\/p>\n<pre class=\"lang:c# theme:vs2012\">mazeLookup = mazes.ToDictionary(l =&gt; l.MazeNumber);<\/pre>\n<p>Then, tweak the algorithm so it no longer loops:<\/p>\n<pre class=\"lang:c# theme:vs2012\">var race = raceLookup[N \/ 3 - 1].ToArray();\r\nvar rat = labRatLookup[race[2].Participant];\r\nvar maze = mazeLookup[race[2].MazeNumber];\r\n\r\nvar result = maze.MazeNumber == race[2].MazeNumber\r\n  &amp;&amp; rat.TrackingId == race[2].Participant\r\n  ? (int)race[2].FinishTime : 0;\r\n\r\nreturn result;<\/pre>\n<p>Below are the results:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-87205\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2020\/05\/Bigo6.png\" alt=\"\" width=\"860\" height=\"89\" \/><\/p>\n<p>Success, performance should remain the same regardless of data input size. This execution time breaks into the nanosecond range. This is exponentially faster than anything I\u2019ve shown before. This follows Big-O theory with good precision, so it is trustworthy.<\/p>\n<p>A similar feat is possible with caching but with some gotchas. Caching large chunks of data and then looping does nothing for performance. When the cache lives outside memory and over the network in another box, large datasets must be deserialized, which spike complexity. This is one reason why caching is not a performance silver bullet. It\u2019s only by caching a narrow slice with a one-to-one lookup that any real gains come in.<\/p>\n<h2>Conclusion<\/h2>\n<p>Big-O notation has a nice way to encapsulate algorithmic complexity. As algorithm complexity grows performance exponentially degrades. Looping spikes complexity and nested loops exponentiate this complexity. .NET provides lookup tables to quell this complexity such as <code>IDictionary&lt;&gt;<\/code>, and <code>ILookup&lt;&gt;<\/code>. Reducing complexity to constant time is the best optimization possible.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every computer science student must learn about Big-O Notation, a way to conceptualize algorithm complexity that directly relates to performance of the algorithm. In this article, Camilo Reyes demonstrates how to apply Big-O algorithms to .NET Core applications.&hellip;<\/p>\n","protected":false},"author":274017,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143538],"tags":[95509],"coauthors":[41241],"class_list":["post-87199","post","type-post","status-publish","format-standard","hentry","category-dotnet-development","tag-standardize"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/87199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/274017"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=87199"}],"version-history":[{"count":7,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/87199\/revisions"}],"predecessor-version":[{"id":87277,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/87199\/revisions\/87277"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=87199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=87199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=87199"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=87199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}