We use the Nvelocity templating engine to produce much of our user-templated text. This includes CMS text, assignment descriptions, and many other places. I've been considering a move to the RazorEngine. No descision has been made yet but I wanted to publish our test results. MethodI looked at several parsing methods. RazorEngine Raw Parse This uses the build-in parse helper method in razor engine with no template name. Razor.Parse(template, model); Razor Compiled parse This uses the same method but adds the template name. By adding the template name RazorEngine will use the compiled version on subsequent calls. Razor.Parse(template, model, "test"); NVelocity Parse This method uses a single NVelocity Parsing Engine Context to perform its work. NVelocity Singleton This method uses the Velocity.Init() and Velocity.Evaluate() methods. This allows NVelocity to track it's own singleton pool of parsers. The TemplatesRazor Template @Model.Name, the narrator, announces his intent to ship aboard a whaling vessel. He has made several voyages as a sailor but none as a whaler. He travels to New Bedford, Massachusetts, where he stays in a whalers’ inn. Since the inn is rather full, he has to share a bed with a harpooner from the South Pacific named Queequeg. At first repulsed by Queequeg’s strange habits and shocking appearance (Queequeg is covered with tattoos), Ishmael eventually comes to appreciate the man’s generosity and kind spirit, and the two decide to seek work on a whaling vessel together. They take a ferry to Nantucket, the traditional capital of the whaling industry. There they secure berths on the Pequod, a savage-looking ship adorned with the bones and teeth of sperm whales. Peleg and Bildad, the Pequod’s Quaker owners, drive a hard bargain in terms of salary. They also mention the ship’s mysterious captain, Ahab, who is still recovering from losing his leg in an encounter with a sperm whale on his last voyage. The Pequod leaves Nantucket on a cold Christmas Day with a crew made up of men from many different countries and races. Soon the ship is in warmer waters, and Ahab makes his first appearance on deck, balancing gingerly on his false leg, which is made from a sperm whale’s jaw. He announces his desire to pursue and kill Moby Dick, the legendary great white whale who took his leg, because he sees this whale as the embodiment of evil. Ahab nails a gold doubloon to the mast and declares that it will be the prize for the first man to sight the whale. As the Pequod sails toward the southern tip of Africa, whales are sighted and unsuccessfully hunted. During the hunt, a group of men, none of whom anyone on the ship’s crew has seen before on the voyage, emerges from the hold. The men’s leader is an exotic-looking man named Fedallah. These men constitute Ahab’s private harpoon crew, smuggled aboard in defiance of Bildad and Peleg. Ahab hopes that their skills and Fedallah’s prophetic abilities will help him in his hunt for Moby Dick. The Pequod rounds Africa @if (Model == null){ <span>Null Here</span> } and enters the Indian Ocean. A few whales are successfully caught and processed for their oil. From time to time, the ship encounters other whaling vessels. Ahab always demands information about Moby Dick from their captains. One of the ships, the Jeroboam, carries Gabriel, a crazed prophet who predicts doom for anyone who threatens Moby Dick. His predictions seem to carry some weight, as those aboard his ship who have hunted the whale have met disaster. While trying to drain the oil from the head of a captured sperm whale, Tashtego, one of the Pequod’s harpooners, falls into the whale’s voluminous head, which then rips free of the ship and begins to sink. Queequeg saves Tashtego by diving into the ocean and cutting into the slowly sinking head. During another whale hunt, Pip, the Pequod’s black cabin boy, VTL Template $Model.Name, the narrator, announces his intent to ship aboard a whaling vessel. He has made several voyages as a sailor but none as a whaler. He travels to New Bedford, Massachusetts, where he stays in a whalers’ inn. Since the inn is rather full, he has to share a bed with a harpooner from the South Pacific named Queequeg. At first repulsed by Queequeg’s strange habits and shocking appearance (Queequeg is covered with tattoos), Ishmael eventually comes to appreciate the man’s generosity and kind spirit, and the two decide to seek work on a whaling vessel together. They take a ferry to Nantucket, the traditional capital of the whaling industry. There they secure berths on the Pequod, a savage-looking ship adorned with the bones and teeth of sperm whales. Peleg and Bildad, the Pequod’s Quaker owners, drive a hard bargain in terms of salary. They also mention the ship’s mysterious captain, Ahab, who is still recovering from losing his leg in an encounter with a sperm whale on his last voyage. The Pequod leaves Nantucket on a cold Christmas Day with a crew made up of men from many different countries and races. Soon the ship is in warmer waters, and Ahab makes his first appearance on deck, balancing gingerly on his false leg, which is made from a sperm whale’s jaw. He announces his desire to pursue and kill Moby Dick, the legendary great white whale who took his leg, because he sees this whale as the embodiment of evil. Ahab nails a gold doubloon to the mast and declares that it will be the prize for the first man to sight the whale. As the Pequod sails toward the southern tip of Africa, whales are sighted and unsuccessfully hunted. During the hunt, a group of men, none of whom anyone on the ship’s crew has seen before on the voyage, emerges from the hold. The men’s leader is an exotic-looking man named Fedallah. These men constitute Ahab’s private harpoon crew, smuggled aboard in defiance of Bildad and Peleg. Ahab hopes that their skills and Fedallah’s prophetic abilities will help him in his hunt for Moby Dick. The Pequod rounds Africa #if ($Model){ <span>Null Here</span> #end and enters the Indian Ocean. A few whales are successfully caught and processed for their oil. From time to time, the ship encounters other whaling vessels. Ahab always demands information about Moby Dick from their captains. One of the ships, the Jeroboam, carries Gabriel, a crazed prophet who predicts doom for anyone who threatens Moby Dick. His predictions seem to carry some weight, as those aboard his ship who have hunted the whale have met disaster. While trying to drain the oil from the head of a captured sperm whale, Tashtego, one of the Pequod’s harpooners, falls into the whale’s voluminous head, which then rips free of the ship and begins to sink. Queequeg saves Tashtego by diving into the ocean and cutting into the slowly sinking head. During another whale hunt, Pip, the Pequod’s black cabin boy, ResultsAll results are in TICKS. 10,000 TICKS = 1 MILLISECOND.
---------------- Begining Test Run 1 ---------------- Razor Raw Parse took 55855585 Razor Compiled parse 1 took 24572457 Razor Compiled Parse 2 took 0 NVelocity Parse took 6130613 NVelocity Parse 2 took 10001 NVelocity Parse 3 template changed took 10001 NVelocity Singleton Parse 1 took 50005 NVelocity Singleton Parse 2 took 10001 ---------------- Begining Test Run 2 ---------------- Razor Raw Parse took 5300530 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 0 NVelocity Parse 2 took 0 NVelocity Parse 3 template changed took 10001 NVelocity Singleton Parse 1 took 0 NVelocity Singleton Parse 2 took 10001 ---------------- Begining Test Run 3 ---------------- Razor Raw Parse took 5560556 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 10001 NVelocity Parse took 10001 NVelocity Parse 2 took 0 NVelocity Parse 3 template changed took 0 NVelocity Singleton Parse 1 took 0 NVelocity Singleton Parse 2 took 10001 ---------------- Begining Test Run 4 ---------------- Razor Raw Parse took 5380538 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 0 NVelocity Parse 2 took 0 NVelocity Parse 3 template changed took 0 NVelocity Singleton Parse 1 took 10001 NVelocity Singleton Parse 2 took 10001 ---------------- Begining Test Run 5 ---------------- Razor Raw Parse took 5270527 Razor Compiled parse 1 took 10001 Razor Compiled Parse 2 took 0 NVelocity Parse took 0 NVelocity Parse 2 took 0 NVelocity Parse 3 template changed took 10001 NVelocity Singleton Parse 1 took 10001 NVelocity Singleton Parse 2 took 10001 ---------------- Begining Test Run 6 ---------------- Razor Raw Parse took 5410541 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 10001 NVelocity Parse 2 took 10001 NVelocity Parse 3 template changed took 0 NVelocity Singleton Parse 1 took 0 NVelocity Singleton Parse 2 took 0 ---------------- Begining Test Run 7 ---------------- Razor Raw Parse took 5380538 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 10001 NVelocity Parse 2 took 10001 NVelocity Parse 3 template changed took 0 NVelocity Singleton Parse 1 took 0 NVelocity Singleton Parse 2 took 0 ---------------- Begining Test Run 8 ---------------- Razor Raw Parse took 5580558 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 10001 NVelocity Parse 2 took 10001 NVelocity Parse 3 template changed took 10001 NVelocity Singleton Parse 1 took 0 NVelocity Singleton Parse 2 took 0 ---------------- Begining Test Run 9 ---------------- Razor Raw Parse took 5470547 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 0 NVelocity Parse 2 took 0 NVelocity Parse 3 template changed took 10001 NVelocity Singleton Parse 1 took 10001 NVelocity Singleton Parse 2 took 0 ---------------- Begining Test Run 10 ---------------- Razor Raw Parse took 5360536 Razor Compiled parse 1 took 0 Razor Compiled Parse 2 took 0 NVelocity Parse took 40004 NVelocity Parse 2 took 10001 NVelocity Parse 3 template changed took 10001 NVelocity Singleton Parse 1 took 10001 NVelocity Singleton Parse 2 took 0
1 Comment
|
Archives
December 2014
Categories |