Me aburria mucho, asi que me puse a medir los tiempos del Indetectables offset locator y se me ocurrio que paralelizando el proceso podria dividir ese tiempo a la mitad.

Indetectables offset locator [Benchmark]:
Dsplit:
Imagen


Avfucker:
Imagen



Mis tiempitos:
Dsplit:
Imagen

Avfucker:
Imagen



Aqui os dejo el código, por si alguno quiere hacerse la GUI, no me voy a matar en daoslo todo hecho tampoco weys yatusa.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace OffsetLocator
{
    class OffsetLocatorApp
    {
        static void Main(string[] args)
        {
            Stopwatch chrono = new Stopwatch();
            chrono.Start();
            Avfucker(@"C:\Users\Esteban\Desktop\WinLauncher\WinLauncher\bin\Release\MiAnotador.exe", 1, 00);
            //Dsplit(@"C:\Users\Esteban\Desktop\WinLauncher\WinLauncher\bin\Release\MiAnotador.exe", 1);
            chrono.Stop();
            Console.WriteLine("Tardo en ejecutarse: "+chrono.ElapsedMilliseconds+ " ms");
        }

        static void Dsplit(string filePath, int nBytes)
        {
            int aux = nBytes;
            if (File.Exists(filePath))
            {
                byte[] fileToSplit = File.ReadAllBytes(filePath);
                Directory.CreateDirectory("dsplited");
                Parallel.For(1000+nBytes, fileToSplit.Length,
                    i =>
                    {
                        if (i % nBytes == 0)
                        {
                            File.WriteAllBytes(""+Directory.GetCurrentDirectory()+"/dsplited/" + i + "_" + nBytes + ".exe", GetByteArray(i, fileToSplit));
                            Interlocked.Increment(ref aux);
                        }
                    }
                );
            }
        }

        static void Avfucker(string filePath, int nBytes, byte fillWith) {
            if (File.Exists(filePath)) {
                byte[] fileToSplit = File.ReadAllBytes(filePath);
                Directory.CreateDirectory("avfucked");
                int c = 0;
                Parallel.For(1000, fileToSplit.Length, i => {
                    File.WriteAllBytes("" + Directory.GetCurrentDirectory() + "/avfucked/" + i + "_" + nBytes + ".exe", FillWithNBytes(fileToSplit, fillWith, i, nBytes));
                    Interlocked.Add(ref c, nBytes);
                }
                );

            }
        }

        static byte[] GetByteArray(int totalSize, byte[] copyFromHere) {
            byte[] result = new byte[totalSize];
            Parallel.For(0, totalSize, i => result[i] = copyFromHere[i]);
            return result;
        }

        static byte[] FillWithNBytes(byte[] file, byte fillWith, int startAt, int inc) {
            byte[] result = file;
            Parallel.For(startAt, startAt+inc,
                i => {
                    result[i] = fillWith;
                }
            );
            return result;
        }

    }
}

Analizemos los tiempos:
Para un fichero de unos 10000 bytes

Para un dsplit a 1 byte:
-> Indetectables offset locator = 1:54 min
-> er mio = 1,2228167


Para un avfucker a 1 byte:
-> Indt offset locator = 4:50 min
-> er mio = 1,77843333 min

Y aunque la diferencia parezca poca, a medida que aumente el tamaño del ejecutable, el offset locator empezará a tardar el doble, el triple, ... y el mio empezara a tardar la mitad, 1/3, 1/4, etc
Es decir, a mayor sea el tamaño del fichero mayor será la diferencia de tiempo entre el indt locator y el mio.
Responder

Volver a “Fuentes”