Skip to content
This repository has been archived by the owner on Mar 2, 2022. It is now read-only.

Seperate mono and netcore runtimes for csharp #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def time_run(cmdline):
('C++', './simple-cpp', './optimized-cpp', '"optimized" isn\'t really optimized'),
('Python', 'python3 simple.py', 'python3 optimized.py', ''),
('Ruby', 'ruby simple.rb', 'ruby optimized.rb', 'by Bill Mill'),
('C#', './simple-cs', None, 'original by John Taylor'),
('C#-mono', './csharp/mono/out/simple-cs', None, 'original by John Taylor'),
('C#-dotnet', 'dotnet csharp/dotnet/simple/out/simple.dll', None, ''),
('AWK', 'gawk -f simple.awk', 'mawk -f optimized.awk', 'optimized uses `mawk`'),
('Forth', '../gforth/gforth-fast simple.fs', '../gforth/gforth-fast optimized.fs', ''),
('Shell', 'bash simple.sh', 'bash optimized.sh', 'optimized does `LC_ALL=C sort -S 2G`'),
Expand Down
2 changes: 2 additions & 0 deletions csharp/dotnet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prerequisites
- Install latest version of .NET core as per instructions: https://dotnet.microsoft.com/
4 changes: 4 additions & 0 deletions csharp/dotnet/simple/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.idea
bin
obj
out
28 changes: 28 additions & 0 deletions csharp/dotnet/simple/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Original version by John Taylor

using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
static void Main(string[] args)
{
var counts = new Dictionary<string, int>();
string line;
while ((line = Console.ReadLine()) != null)
{
line = line.ToLower();
var words = line.Split(' ', StringSplitOptions.RemoveEmptyEntries);
foreach (string word in words)
{
counts[word] = counts.GetValueOrDefault(word, 0) + 1;
}
}
var ordered = counts.OrderByDescending(pair => pair.Value);
foreach (var entry in ordered)
{
Console.WriteLine("{0} {1}", entry.Key, entry.Value);
}
}
}
8 changes: 8 additions & 0 deletions csharp/dotnet/simple/simple.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
2 changes: 2 additions & 0 deletions csharp/mono/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Prerequisites
- Install mono as per instructions on: https://www.mono-project.com/
File renamed without changes.
14 changes: 10 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,16 @@ echo Unix shell optimized
bash optimized.sh <kjvbible_x10.txt | awk '{ print $2, $1 }' | python3 normalize.py >output.txt
git diff --exit-code output.txt

echo C# simple
csc -optimize -out:simple-cs simple.cs
chmod +x simple-cs
./simple-cs <kjvbible_x10.txt | python3 normalize.py >output.txt
echo C#-mono simple
mkdir -p csharp/mono/out/
csc -optimize -out:csharp/mono/out/simple-cs csharp/mono/simple.cs
chmod +x csharp/mono/out/simple-cs
./csharp/mono/out/simple-cs <kjvbible_x10.txt | python3 normalize.py >output.txt
git diff --exit-code output.txt

echo C#-dotnet simple
dotnet build -c Release -o csharp/dotnet/simple/out csharp/dotnet/simple/
dotnet csharp/dotnet/simple/out/simple.dll <kjvbible_x10.txt | python3 normalize.py >output.txt
git diff --exit-code output.txt

echo nim simple
Expand Down