Skip to content
Open
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: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@


English readme not available at this time, it's only available in [french](readme.fr.md)

Narrainasamy Jeremy
Marzilli Gaetan
106 changes: 106 additions & 0 deletions Students/narrainasamy-jeremy/nget-v1/nget-v1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Created by SharpDevelop.
* User: Jkn1092
* Date: 01/06/2015
* Time: 17:43
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;

namespace nget_v1
{
class Program
{
public static void Main(string[] args)
{

switch(args.Length){
case 3:
if(args[0] == "get" && args[1] == "-url"){
var contenu = getContenuUrl(args[2]);
Console.WriteLine(contenu);
}else{
Console.WriteLine("Une erreur est survenue : Nombre d'arguments insuffisant");
}
break;

case 5:
if(args[0] == "get" && args[1] == "-url" && args[3] == "-save"){
var contenu = getContenuUrl(args[2]);
System.IO.File.WriteAllText(args[4],contenu);
}
else if(args[0] == "test" && args[1] == "-url" && args[3] == "-times"){
var nbTest = Convert.ToInt32(args[4]);

for(var i = 0; i < nbTest; i++){
var temps = getChargementUrl(args[2]);
Console.WriteLine(temps.TotalSeconds);
}

}else{
Console.WriteLine("Une erreur est survenue : Nombre d'arguments in");
}
break;

case 6:
if(args[0] == "test" && args[1] == "-url" && args[3] == "-times" && args[5] == "-avg"){

var nbTest = Convert.ToInt32(args[4]);
var listeTemps = new List<TimeSpan>();

for(var i = 0; i < nbTest; i++){
listeTemps.Add(getChargementUrl(args[2]));
}

var moyenne = TimeSpan.FromSeconds(listeTemps.Average(time=>time.TotalSeconds));
Console.WriteLine(moyenne);

}else{
Console.WriteLine("Une erreur est survenue : Nombre d'arguments in");
}
break;

default:
Console.WriteLine("Une erreur est survenue : Nombre d'arguments in");
break;
}

Console.Write("Press any key to exit . . . ");
Console.ReadKey(true);
}

public static String getContenuUrl(String url){

var client = new WebClient();
client.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

var data = client.OpenRead (url);
var reader = new StreamReader (data);
var s = reader.ReadToEnd ();

data.Close ();
reader.Close ();

return s;
}

public static TimeSpan getChargementUrl(String url){

var request = (HttpWebRequest)WebRequest.Create(url);
System.Diagnostics.Stopwatch timer = new Stopwatch();

timer.Start();
var response = (HttpWebResponse)request.GetResponse();
timer.Stop();

return timer.Elapsed;
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#region Using directives

using System;
using System.Reflection;
using System.Runtime.InteropServices;

#endregion

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("nget-v1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("nget-v1")]
[assembly: AssemblyCopyright("Copyright 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]

// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
6 changes: 6 additions & 0 deletions Students/narrainasamy-jeremy/nget-v1/nget-v1/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
61 changes: 61 additions & 0 deletions Students/narrainasamy-jeremy/nget-v1/nget-v1/nget-v1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{7F591218-AA4B-4C94-B566-675AD9026AC8}</ProjectGuid>
<ProjectTypeGuids>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Exe</OutputType>
<RootNamespace>nget_v1</RootNamespace>
<AssemblyName>nget-v1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<NoWin32Manifest>False</NoWin32Manifest>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<StartAction>Project</StartAction>
<StartArguments>test -url "https://msdn.microsoft.com/fr-fr/library/system.net.webclient%28v=vs.110%29.aspx" -times 2 -avg</StartArguments>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
18 changes: 18 additions & 0 deletions Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 5.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nget-v2", "nget-v2\nget-v2.csproj", "{730E5EEA-EDEF-495C-A6D6-97334E0998FD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{730E5EEA-EDEF-495C-A6D6-97334E0998FD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
76 changes: 76 additions & 0 deletions Students/narrainasamy-jeremy/nget-v2/nget-v2/nget-v2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* Created by SharpDevelop.
* User: Jkn1092
* Date: 17/06/2015
* Time: 15:58
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;

namespace nget_v2
{
class Program
{

public static void Main(string[] args)
{

try{

if(args[0].Equals("get")){
if(args.Contains("-url") && args.Contains("-save")){ System.IO.File.WriteAllText(getValeurParametre(args,"-save"),getContenuUrl(getValeurParametre(args,"-url"))); return;}
if(args.Contains("-url")){ Console.WriteLine(getContenuUrl(getValeurParametre(args,"-url"))); return;}
}

if(args[0].Equals("test")){
if(args.Contains("-url") && args.Contains("-times") && args.Contains("-avg")){ getChargementUrl(getValeurParametre(args,"-url"), int.Parse(getValeurParametre(args,"-times")), true); return;}
if(args.Contains("-url") && args.Contains("-times")){ getChargementUrl(getValeurParametre(args,"-url"), int.Parse(getValeurParametre(args,"-times")), false); return;}
}

}catch(Exception e){
Console.WriteLine("Une erreur est survenue : " + e);
}

}

public static string getValeurParametre(string[] args, string parametre){
return args[Array.IndexOf(args,parametre)+1];
}

public static String getContenuUrl(String url){
var client = new WebClient();
var s = client.DownloadString(url);
return s;
}

public static void getChargementUrl(String url, int nbTest, bool avg){
var request = (HttpWebRequest)WebRequest.Create(url);
System.Diagnostics.Stopwatch timer = new Stopwatch();

var listeTemps = new List<TimeSpan>();

for(var i = 0; i < nbTest; i++){
timer.Start();
var response = (HttpWebResponse)request.GetResponse();
timer.Stop();

if(avg){
listeTemps.Add(timer.Elapsed);
}else{
Console.WriteLine(timer.Elapsed.TotalSeconds);
}
}

if(avg){
Console.WriteLine(TimeSpan.FromSeconds(listeTemps.Average(time=>time.TotalSeconds)).TotalSeconds);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#region Using directives

using System;
using System.Reflection;
using System.Runtime.InteropServices;

#endregion

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("nget-v2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("nget-v2")]
[assembly: AssemblyCopyright("Copyright 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]

// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration>
Loading