コード例 #1
0
ファイル: ServiceBase.cs プロジェクト: narqs/libvideo
 /// <summary>
 /// Retrieves the <see cref="IEnumerable{Video}"/> specified by <paramref name="videoUri"/> as an asynchronous operation.
 /// </summary>
 /// <param name="videoUri">The URL to visit.</param>
 /// <returns>A <see cref="Task"/> of the <see cref="IEnumerable{Video}"/> representing the information from <paramref name="videoUri"/>.</returns>
 public async Task<IEnumerable<Video>> GetAllVideosAsync(string videoUri)
 {
     using (var wrapped = new ClientService(this))
     {
         return await wrapped
             .GetAllVideosAsync(videoUri)
             .ConfigureAwait(false);
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: narqs/libvideo
        static void Main(string[] args)
        {
            int times = args.Length == 0 ? 3 : int.Parse(args[0]);
            int iterations = args.Length <= 1 ? 2 : int.Parse(args[1]);

            Console.WriteLine("Starting...");
            Console.WriteLine($"Times: {times}.");
            Console.WriteLine($"Iterations: {iterations}.");
            Console.WriteLine("Getting results for YoutubeExtractor...");

            var elapsed = TimeSpan.Zero;

            for (int i = 0; i < times; i++)
            {
                RunChecked(() =>
                {
                    var watch = Stopwatch.StartNew();

                    for (int j = 0; j < iterations; j++)
                        GC.KeepAlive(DownloadUrlResolver.GetDownloadUrls(Uri));

                    watch.Stop();
                    elapsed += watch.Elapsed;
                });
            }

            Console.WriteLine($"YoutubeExtractor: took {elapsed}.");
            Console.WriteLine("Getting results for libvideo...");

            elapsed = TimeSpan.Zero;

            using (var service = new ClientService(new YouTubeService()))
            {
                for (int i = 0; i < times; i++)
                {
                    RunChecked(() =>
                    {
                        var watch = Stopwatch.StartNew();

                        for (int j = 0; j < iterations; j++)
                            GC.KeepAlive(service.GetAllVideos(Uri));

                        watch.Stop();
                        elapsed += watch.Elapsed;
                    });
                }
            }

            Console.WriteLine($"libvideo: took {elapsed}.");
        }