forked from kimlaine/bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Examples.cs
87 lines (75 loc) · 3.55 KB
/
Examples.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
using Microsoft.Research.SEAL;
using System;
namespace SEALNetExamples
{
partial class Examples
{
static void Main(string[] args)
{
while (true)
{
Console.WriteLine("+---------------------------------------------------------+");
Console.WriteLine("| The following examples should be executed while reading |");
Console.WriteLine("| comments in associated files in dotnet/examples/. |");
Console.WriteLine("+---------------------------------------------------------+");
Console.WriteLine("| Examples | Source Files |");
Console.WriteLine("+----------------------------+----------------------------+");
Console.WriteLine("| 1. BFV Basics | 1_BFV_Basics.cs |");
Console.WriteLine("| 2. Encoders | 2_Encoders.cs |");
Console.WriteLine("| 3. Levels | 3_Levels.cs |");
Console.WriteLine("| 4. CKKS Basics | 4_CKKS_Basics.cs |");
Console.WriteLine("| 5. Rotation | 5_Rotation.cs |");
Console.WriteLine("| 6. Performance Test | 6_Performance.cs |");
Console.WriteLine("+----------------------------+----------------------------+");
/*
Print how much memory we have allocated from the current memory pool.
By default the memory pool will be a static global pool and the
MemoryManager class can be used to change it. Most users should have
little or no reason to touch the memory allocation system.
*/
ulong megabytes = MemoryManager.GetPool().AllocByteCount >> 20;
Console.WriteLine("[{0,7} MB] Total allocation from the memory pool", megabytes);
ConsoleKeyInfo key;
do
{
Console.WriteLine();
Console.Write("> Run example (1 ~ 6) or exit (0): ");
key = Console.ReadKey();
Console.WriteLine();
} while (key.KeyChar < '0' || key.KeyChar > '6');
switch (key.Key)
{
case ConsoleKey.D1:
ExampleBFVBasics();
break;
case ConsoleKey.D2:
ExampleEncoders();
break;
case ConsoleKey.D3:
ExampleLevels();
break;
case ConsoleKey.D4:
ExampleCKKSBasics();
break;
case ConsoleKey.D5:
ExampleRotation();
break;
case ConsoleKey.D6:
ExamplePerformanceTest();
break;
case ConsoleKey.D0:
return;
default:
Console.WriteLine(" [Beep~~] Invalid option: type 0 ~ 6");
break;
}
/*
Force a garbage collection after each example to accurately show memory pool use.
*/
GC.Collect();
}
}
}
}