• 大小: 0.02M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-08
  • 语言: 其他
  • 标签: 其他  

资源简介

20170526154614428.Net程序突破内存2G访问限制的程序代码.zip

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace AweSimple
{
    class Program
    {
        static void TestSpeed()
        {
            try
            {
                byte[] inputBuffer = new byte[1024];

                Stopwatch stopWatch = new Stopwatch();

                using (AweStream.AweStream aweStream = new AweStream.AweStream(1024 * 1024 * 100))
                {
                    //Map
                    aweStream.Map();
                    stopWatch.Start();

                    //Copy one bytes
                    //Use unsafe pointer
                    for (int i = 0; i < 1024 * 1024 * 100; i++)
                    {
                        unsafe
                        {
                            aweStream.LpMemory[i] = 1;
                        }
                    }

                    stopWatch.Stop();

                    Console.WriteLine(stopWatch.ElapsedMilliseconds);

                    aweStream.Position = 0;

                    
                    //Block copy
                    stopWatch.Reset();
                    stopWatch.Start();

                    for (int i = 0; i < 1024 * 100; i++)
                    {
                        unsafe
                        {
                            aweStream.Write(inputBuffer 0 1024);
                        }
                    }

                    stopWatch.Stop();

                    Console.WriteLine(stopWatch.ElapsedMilliseconds);

                    //UnMap
                    aweStream.UnMap();
                }

                byte[] ManageBuf = new byte[1024 * 1024 * 100];

                stopWatch.Reset();
                stopWatch.Start();

                for (int i = 0; i < 1024 * 1024 * 100; i++)
                {
                    ManageBuf[i] = 1;
                }

                stopWatch.Stop();

                Console.WriteLine(stopWatch.ElapsedMilliseconds);

                stopWatch.Reset();
                stopWatch.Start();

                for (int i = 0; i < 1024 * 100; i++)
                {
                    Array.Copy(inputBuffer 0 ManageBuf i * 1024 1024);

                }

                stopWatch.Stop();

                Console.WriteLine(stopWatch.ElapsedMilliseconds);

            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

        }

        static void Main(string[] args)
        {
            TestSpeed();

            string input = Console.ReadLine();
            List aweStreams = new List();

            while (true)
            {
                switch (input)
                {
                    case “a“:
                        try
                        {
              

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2008-11-06 17:03  AweSimple\
     文件        2265  2008-11-04 17:49  AweSimple\AweSimple.csproj
     文件        5361  2008-11-06 16:45  AweSimple\Program.cs
     目录           0  2008-11-04 18:05  AweSimple\Properties\
     文件        1298  2008-11-04 18:05  AweSimple\Properties\AssemblyInfo.cs
     目录           0  2008-11-06 17:03  AweStream\
     文件       11105  2008-11-06 15:46  AweStream\AweStream.cs
     文件        2449  2008-11-06 15:20  AweStream\AweStream.csproj
     文件         692  2008-11-04 17:38  AweStream\AweStreamException.cs
     目录           0  2008-11-04 18:05  AweStream\Properties\
     文件        1421  2008-11-04 18:05  AweStream\Properties\AssemblyInfo.cs
     目录           0  2008-11-06 15:20  AweStream\Win32\
     文件        2748  2008-11-06 15:20  AweStream\Win32\AweApi.cs
     文件        1686  2008-11-06 15:20  AweStream\Win32\Buffer.cs
     文件        2208  2008-11-06 15:20  AweStream\Win32\General.cs
     文件        5009  2008-11-06 15:20  AweStream\Win32\LoggedSetLockPagesPrivilege.cs
     文件         551  2008-11-06 15:18  AweStream\Win32\LoggedSetLockPagesPrivilegeException.cs
     文件        1397  2008-11-04 12:15  AweSimple.sln
     文件       35328  2008-11-06 17:02  AweSimple.suo

评论

共有 条评论