gavinpugh / vs-android

Integrated development of Android NDK C/C++ software with Microsoft Visual Studio.
Other
119 stars 34 forks source link

Delay to Log - Delay to Build #126

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Build a project

What is the expected output? What do you see instead?

I expect to see fast output of each file being compiled. Something like a bunch 
of 3 or 4 files per second. And a fast output of each log output line.

Instead, I see something like 3 or 4 seconds per file and 1 to 2 seconds per 
log line output.

I think it is not related to compiler, because in Linux, OS X and MSVC the 
output is much faster (besides another platform, is it an Android compiler 
issue?)

I think this is related something in the way between compiler output and 
Logging to Visual Studio Output. I noticed that even for "atomic warnings" but 
that spawns to multiple lines, each line of the same warning has a delay of 2 
or 3 seconds for outputing.

What version of the product are you using? On what operating system?

vs-android 963 with VS2013 in Windows 8.1

Original issue reported on code.google.com by camil...@gmail.com on 23 Sep 2014 at 8:32

GoogleCodeExporter commented 9 years ago
Not able to reproduce this myself, output is fast just like Win32/x64 CL 
compilation for me.

I'll happily integrate a patch if you are able to identify and fix the cause 
yourself.

Original comment by gavin.dj.pugh on 29 Oct 2014 at 9:21

GoogleCodeExporter commented 9 years ago
Hi,

By debugging the dll (in MSBuild.exe) I found that the 4th RegEx at Util.cs was 
running very slow for me.

So, I have done a change to evaluate and do the replacement of the 4th Regex by 
a function (which I cannot say if it is very correctly because I did not 
understand very well the RegEx's) (Code at the end).

After doing that, the build was really faster for many logging points.

        private static Regex[] REGEX_GCC_REGEX_MATCH = new Regex[4];

        public static bool do4(ref string lineRetParam, string line)
    {
            int i = 0;

            string lineRet;

            while (i < line.Length && System.Char.IsWhiteSpace(line[i]))
            {
                i++;
            }

            if (i >= line.Length)
                return false;

            int i1 = i;

            while (i < line.Length && line[i] != ':')
            {
                i++;
            }

            if (i >= line.Length)
                return false;

            int i2 = i;

            while (i < line.Length && line[i] != ':')
            {
                i++;
            }

            if (i >= line.Length)
                return false;

            int i3 = i;

            if (i < line.Length && (!System.Char.IsDigit(line[i]) || line[i] == '0'))
                return false;

            while (i < line.Length && line[i] != ':')
            {
                if (!System.Char.IsDigit(line[i]))
                    return false;
                i++;
            }

            if (i >= line.Length)
                return false;

            int i4 = i;

            string filename = line.Substring(i2, i3 - i1);

            string absPath = Path.GetFullPath(filename);

            lineRet = absPath + "(" + line.Substring(i3, i4 - i3) + "): " + "'" + line.Substring(i1, i2 -i1) + "'" + line.Substring(i4);

            lineRetParam = lineRet;

            return true;
    }

        public static string GCCOutputReplace(string line)
        {
            // Replaces given GCC style output, with output that obeys Visual Studio's 'jump to line' formatting. So:
            //      CppSource/demo.c:51: error: conflicting types for 'seedRandom'
            // becomes:
            //      c:\Projects\san-angeles\CppSource\demo.c(51) error: conflicting types for 'seedRandom'

            for (int i = 0; i < GCC_REGEX_MATCH.Length; i++)
            {
                // Do we match this...?
                if(i == 3)
                {
                    if(do4(ref line, line))
                        return line;
                    continue;
                }
                Regex regEx = REGEX_GCC_REGEX_MATCH[i];
                if(REGEX_GCC_REGEX_MATCH[i] == null)
                {
                    REGEX_GCC_REGEX_MATCH[i] = new Regex(GCC_REGEX_MATCH[i]);
                    regEx = REGEX_GCC_REGEX_MATCH[i];
                }
                if (regEx.IsMatch(line))
                {
                    // Good, we do. For now just grab the filename portion
                    string filename = regEx.Replace(line, GCC_REGEX_FILENAME[i]);

                    try
                    {
                        // Brackets cause issues:
                        // C:\Projects\vs-android\vs-android_samples\san-angeles\CppSource\cams.h(49) error; (near initialization for 'sCamTracks[0]')
                        // So I'll remove them first
                        //line = line.Replace("(", "");
                        //line = line.Replace(")", "");

                        // Attempt to convert to a fullpath. We'll drop out of this regex attempt if it fails, it'll throw an Exception.
                        string absPath = Path.GetFullPath(filename);

                        // All good then. Just do the final regex replace, appended after the resolved filename.
                        string lastBit = regEx.Replace(line, GCC_REGEX_REPLACE[i]);

                        string newLine = absPath + lastBit;

                        return newLine;
                    }
                    catch
                    {
                        continue;
                    }
                }
            }

            return line;
        }

    }

Original comment by camil...@gmail.com on 4 Nov 2014 at 9:45