Giter VIP home page Giter VIP logo

time-grunt's Introduction

Deprecated

Deprecated because Grunt is practically unmaintained. Move on to something better. This package will continue to work with Grunt v1, but it will not receive any updates.


time-grunt Build Status

Display the elapsed execution time of grunt tasks

Install

$ npm install --save-dev time-grunt

Usage

// Gruntfile.js
module.exports = grunt => {
	// require it at the top and pass in the grunt instance
	require('time-grunt')(grunt);

	grunt.initConfig();
}

Optional callback

If you want to collect the timing stats for your own use, pass in a callback:

require('time-grunt')(grunt, (stats, done) => {
	// do whatever you want with the stats
	uploadReport(stats);

	// be sure to let grunt know when to exit
	done();
});

Clean layout

The watch task and tasks that take less than 1% of the total time are hidden to reduce clutter.

Run grunt with grunt --verbose to see all tasks.

Run grunt with grunt --quiet to quiet all tasks including time-grunt.

License

MIT © Sindre Sorhus

time-grunt's People

Contributors

adrianlee44 avatar demmer avatar dominykas avatar donaldpipowitch avatar dylang avatar geddski avatar jeremycarlsten avatar kevva avatar ntwb avatar peol avatar simshanith avatar sindresorhus avatar sorich87 avatar tomasstankovic avatar tomgault avatar zubb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

time-grunt's Issues

Feature request: Ignore Tasks

A way to ignore some tasks would be great. For example: The "watch" tasks takes hours to complete (because it is just waiting) and measuring the time there makes no sense.

Not outputting total elapsed time unless grunt is called with `--no-color` option

I'm having an issue where time-grunt does not output the total elapsed time but only outputs the time for each separate task as shown in the image below. I randomly noticed this because I tried running grunt from Sublime Text 3 rather than PowerShell and in the ST3 console the total elapsed time was correctly displayed. After fiddling with it a little I found out that I can make it appear in PowerShell if I call grunt with the --no-color option.
I know that this may not be an issue with time-grunt but rather with PowerShell but I thought I'd ask here to hear if you have any idea what might cause this.

time-grunt-builddeploy

Time bars not displayed as expected on the environment where ambiguous-width characters are treated as double width

I have a problem with time-grunt on my terminal.

Some terminal emulators, for example the built-in terminal.app on MacOSX, support a setting to treat Unicode East Asian Ambiguous characters as double width (see http://www.unicode.org/reports/tr11/ for details). Those who use East Asian (CJK) characters (like me) are likely to turn the setting on, and thus the time bars which use ambiguous characters are not displayed as expected.

Execution start time is always in UTC

The execution start time is always in UTC. Was looking in the code and it would be great if we can add support to show the time in current timezone. Its really helpful when you are running builds in multiple windows or trying to figure out when you built the last time.

Ignore some tasks

Some tasks are not really worth viewing time for, such as Watch which may be left running and would always be the lion's share of time.

Usage of `ms` conversion lib gives imprecise results.

Tasks that take longer than 1 full second lose the millisecond precision, left with only whole second values. Personally, I would like less rounding and more precision, knowing at least how many 10ths of a second it took.

Support for grunt-concurrent

time-grunt and grunt-concurrent are great but time-grunt doesn't display the time of each task started by grunt-concurrent. It only displays the whole concurrent task, which is not really meaningful.

Percentage generates error for very long names

The percentage feature (nice feature!) added by @dylang breaks when the task name > 80 characters with the error RangeError: Invalid array length at createBar (/xxx/node_modules/time-grunt/time-grunt.js:47:14)

By example grunt-newer which was recently added to generator-angular and generator-webapp generates tasks names like "newer-timestamp:jshint:all:/Users/xxx/Documents/bricks/node_modules/grunt-newer/.cache"

Timing only specific tasks

Is there a way to target a specific task to be timed? Instead of the overall progress?

I have multiple grunt projects under a parent grunt-hub. All my projects have time-grunt on them so I don't necessarily need the parent project to show me the result when I trigger a build. Individual stats are sufficient. However, when I run a distribution task, I'd like to only get the overall build stats and turn off time-grunt for individual tasks. Is it as simple as:

grunt.registerTask('dist', 'Runs the distribution build', function() {
      timeGrunt(grunt);
      ...
});

Or would I have to do something different?

Ctrl+C not working

When using time-grunt you can't Ctrl+C to kill grunt anymore. It just continues and ignores the event completely and exits when it's done.

Ubuntu 14.04.3 LTS
node v0.12.1
grunt-cli v0.1.13
grunt v0.4.5

Changing output color

The color in your screenshot is perfect, however for us using gitbash the color is a dark blue and unreadable. Is there a way to change the color? we are using 1.0.0

node-exit hack still necessary?

cowboy/node-exit#4 has been resolved, so I was curious if this is still needed:

    // crazy hack to work around stupid node-exit
    function exit(exitCode) {
        clearInterval(interval);
        process.emit('timegruntexit', exitCode);
        exit = function () {};
    }

RangeError: Invalid Array Length

Not really sure what's causing this, but I'm suddenly getting an Invalid Array Length exception thrown.
It only happens in rare instances when I run grunt, even if I don't change anything.

         │Execution Time (2014-06-16 16:41:05 UTC)
         │
         │RangeError: Invalid array length
         │    at createBar (/home/kevine/solutions-ng/node_modules/time-grunt/time-grunt.js:105:14)
         │    at /home/kevine/solutions-ng/node_modules/time-grunt/time-grunt.js:114:53
         │    at Array.map (native)
         │    at formatTable (/home/kevine/solutions-ng/node_modules/time-grunt/time-grunt.js:109:38)
         │    at process.<anonymous> (/home/kevine/solutions-ng/node_modules/time-grunt/time-grunt.js:150:7)
         │    at process.g (events.js:180:16)
         │    at process.EventEmitter.emit (events.js:95:17)
         │    at process.exit (/home/kevine/solutions-ng/node_modules/time-grunt/time-grunt.js:43:11)
         │    at tryToExit (/home/kevine/solutions-ng/node_modules/grunt/node_modules/exit/lib/exit.js:17:15)

I reran grunt right after it, and it worked fine.

optional callback

It would be nice if time-grunt accepted an optional callback function that gets passed the timing stats. For my case I'm wanting to build a graph of my grunt tasks' speed over time. Would you accept a PR for this?

Only Showing Total Elapsed Time

Seeing this behavior in a private repo. Added you as a contributor in case you want to check it out.

Basically, using a bunch of grunt tasks like concat, usemin, rev, etc

Would be awesome to see how long each of these tasks is taking, to zero in on where I should be optimizing. But I'm only seeing the total...
screen shot 2013-08-07 at 3 50 13 pm

allow custom barChar character, or non utf8 option

not all logging environments support utf8 which can result in - � instead of ▇

it would be nice to replace it with the line character in 'figure', assuming its a ASCII char.

unfortunately its not clear how i might pass config option to grunt-time. might be obvious after a little digging.

this would also address this issue - #52

`time-grunt` doesn't work at all

Since time-grunt wasn't working in my project, I tried it on an example Gruntfile:

module.exports = function (grunt) {
    'use strict';

    // require it at the top and pass in the grunt instance
    require('time-grunt')(grunt);

    grunt.initConfig();
    grunt.registerTask('default', []);
};

and I still see no output, even in verbose mode:

$ grunt --verbose
Initializing
Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ default

No tasks specified, running default tasks.
Running tasks: default

Running "default" task

Done, without errors.

I'm on OS X 10.9, the package.json file used for this example is as follows:

{
    "name": "test-app",
    "version": "0.0.0",
    "devDependencies": {
        "grunt": "0.4.2",
        "time-grunt": "0.2.3"
    }
}

Divide by zero error if totalTime == 0

At (Line 109)[https://github.com/sindresorhus/time-grunt/blob/master/index.js#L109] add isNaN check.

        if (isNaN(avg) ||  (avg < 0.01 && !grunt.option('verbose'))) {
            return;
        }

Miscalculation of task title length

there seems to be a little miscalculation in the part that shortens executed task titles in the summary:.

eg.

Execution Time (2014-03-21 11:06:16 UTC)
loading tasks        2.9s  ▇ 5%
copy:verb           12.9s  ▇▇▇▇ 21%
compass:...ckicons  21.4s  ▇▇▇▇▇▇ 35%
compass:...awesome   1.3s  ▇ 2%
compass:bootstrap    4.1s  ▇▇ 7%
compass:theme       750ms  ▇ 1%
autopref...r:style   1.8s  ▇ 3%
cssmin:global          1s  ▇ 2%
modernizr:dist        11s  ▇▇▇▇ 18%
uglify:h...rscript   3.5s  ▇ 6%

task 3 is "compass:stackicons" and could be written out (sta instead ...)
task 7 is "autoprefixer:style" and could be written out (ixe instead ...)

not sure if that is regarded as by design or a bug.

[feature] Allow depth configuration or whitelist

In order to be able to see how much it takes for subtask which are regrouped for "lisibility"/"usage" while still having the end-report, having a whitelist or a depth configuration would be nice :)

Configurable column width.

I use powershell set to 3000 columns which makes time-grunt unhelpful when 1% tasks have 30 tick marks. Can the column width be a configurable value? At the moment, I just hardcode the width to 80 on line 74.

Color as an option

Could you put in an option to switch between the different chalk colors, the dark blue is very unreadable in my console.

I can code it up and do a PR if you want.

TypeError: chalk.stripColor is not a function

Execution Time (2016-03-28 23:56:07 UTC)
/Users/bcherny/foo/node_modules/time-grunt/index.js:140
        return chalk.stripColor(str).length;
                     ^

TypeError: chalk.stripColor is not a function
    at table.stringLength (/Users/bcherny/foo/node_modules/time-grunt/index.js:140:18)
    at /Users/bcherny/foo/node_modules/text-table/index.js:33:21
    at Array.forEach (native)
    at forEach (/Users/bcherny/foo/node_modules/text-table/index.js:73:31)
    at /Users/bcherny/foo/node_modules/text-table/index.js:32:9
    at Array.reduce (native)
    at reduce (/Users/bcherny/foo/node_modules/text-table/index.js:63:30)
    at module.exports (/Users/bcherny/foo/node_modules/text-table/index.js:31:17)
    at formatTable (/Users/bcherny/foo/node_modules/time-grunt/index.js:137:10)
    at process.<anonymous> (/Users/bcherny/foo/node_modules/time-grunt/index.js:163:7)

Naming

Why not use grunt-time to be more consistent?

Grunt stuck with time-grunt and --no-color

The time table is displayed, the process.exit() is called, but the node process does not exit.

No problem without the --no-color option.

How can I help ?

node version 10.0.23
grunt 0.4.2

Time-Grunt measures only half of execution time - Is that normal?

Hello and thanks for helpful and very easy to use plugin!

Simple question - Time-Grunt measures only half of the actualy compilation time. Is that normal behaviour? Specifically: In my current enviroment, Grunt-Time shows 2.6s as an execution time and Grunt's total is 4.831s.

RIght now, I'm running Grunt on my Vagrant virtual machine (hashicorp/precise64) on Mac OSX (which, of course, may cause a variety of lags).

Thanks!

Format time length differently for longer-running tasks

If I have a long-running task, the formatting isn't as helpful:

Execution Time (2014-03-19 14:25:14 UTC)
loading tasks              8s  ▇▇▇▇ 2%
mochaProtractor:local  412.4s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 98%
Total 422s

What if the date formatting used minutes when applicable? I think the following is more readable:

Execution Time (2014-03-19 14:25:14 UTC)
loading tasks              8s   ▇▇▇▇ 2%
mochaProtractor:local  6m52.4s  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 98%
Total 7m2s

Cannot find module 'time-grunt'

Hello and sorry for my english.

I try install time-grunt local and global, clear npm cache, update npm, but nothing helps.
I get:
Loading "Gruntfile.js" tasks...ERROR

Error: Cannot find module 'time-grunt'
Warning: Task "default" not found. Use --force to continue.

My version od packages:
node: '0.10.31',
npm: '1.4.23'

After run:
npm install --save-dev time-grunt
in package.json state:
"devDependencies": {
"grunt": "^0.4.5",
...
"time-grunt": "^1.0.0"
}

I not understand what is wrong.

Disable for independent runs

When we run our grunt tasks via maven or grunt-cli the time section is awesome! However, we use intellij and Karma to run our jasmine tests and it gets in the way. Is there anyway to disable it for a particular command?

grunt karma --grunt-time disable ??

Log with ambiguous-width characters

Hi.

I have a issue about Logging for Execution Time.

I'm using Max OSX with iTerm2 Build 2.0.0.20141103

and my setting with iTerm2 below:

✓ Treat ambiguous-width characters as double width

require('figures').square: This chars is ambiguous-width chars.

What do you think about using another chars like require('figures').squareSmallFilled?

square (not as double width)

2014-12-03 22 26 54

square (as double width)

2014-12-03 22 27 11

squareSmallFilled (as double width)

2014-12-03 22 27 54

Command line support

It would be cool if you could use this plugin manually via command line, that way you could use it without grunt (if you happen to simply use npm as build tool).

timegrunt --start 'building css'
timegrunt --end 'building css'
timegrunt --render

Maintainer needed

I don't have the time to maintain this anymore. Luckily it's very stable, so it won't be deprecated or anything like that. However, there are some minor issues that could use fixing and there might be more in the future when Grunt 1.0 is released. This plugin is used by a lot of grunt projects (443,282 downloads in the last month), so it would be nice if someone stepped up. Happy to add multiple people.

Blue chalk colour for Windows hard to read

Not sure if this is a problem with my colour blindness but I'm finding the blue colour really difficult to read in Windows command prompt.

I've modified chalk.blue to chalk.cyan on line 111 and chalk.bold.blue to chalk.bold.cyan on 120 and find this much easier to read.

Is cyan an offensive colour to anyone else, could these colours even be configurable?

Customizing colors

Just went into a situation, that the current color of the bars and percentages are very difficult to read on a display with blue on black.

Went through the code a bit, it seems colors are hard coded. It would be great to have a customize color feature.

qq 20141022091159

Abstracted grunt hooks package

I needed to do something similar to this plugin where it hooks into grunt's tasks. I pulled out the code for the grunt hooks from this package into another package and wrote tests(!): https://github.com/TheSavior/grunt-before-after-hooks

Would you guys be open to a PR refactoring this module on top of that to not have duplicated code doing this? I'm more than happy to add all of the contributors to this repo to the other one.

Support for grunt watch?

It would be cool to support when tasks are being run in grunt-watch (becuase you can easily remove to default output from watch with the dateFormat option in grunt-watch). I might take a swing at it next week but I wanted to file a bug so I don't forget :)

builder is not defined

I'm having very strange error, that appeared after angular-ui-grid being installed to the project. It sounds totally unrelated, but now when I run grunt build:dev, I have such error,

Users/alexanderbeletsky/Development/Projects/mylorry/shift-planner-office/node_modules/time-grunt/node_modules/chalk/index.js:40
        return applyStyle.apply(builder, arguments);
                                ^
ReferenceError: builder is not defined
    at Chalk.builder (/Users/alexanderbeletsky/Development/Projects/mylorry/shift-planner-office/node_modules/time-grunt/node_modules/chalk/index.js:40:27)
    at process.<anonymous> (/Users/alexanderbeletsky/Development/Projects/mylorry/shift-planner-office/node_modules/time-grunt/index.js:155:22)
    at process.g (events.js:199:16)
    at process.emit (events.js:107:17)
    at process.exit (/Users/alexanderbeletsky/Development/Projects/mylorry/shift-planner-office/node_modules/time-grunt/index.js:41:11)
    at tryToExit (/Users/alexanderbeletsky/Development/Projects/mylorry/shift-planner-office/node_modules/grunt/node_modules/exit/lib/exit.js:17:15)

It's from chalk library,

function build(_styles) {
    var builder = function builder() {
        return applyStyle.apply(builder, arguments);
    };

    builder._styles = _styles;
    builder.enabled = this.enabled;
    // __proto__ is used because we must return a function, but there is
    // no way to create a function with a different prototype.
    /*eslint no-proto: 0 */
    builder.__proto__ = proto;

    return builder;
}

Which looks like a valid code. Any pointers will be appreciated.

› node --version
v0.12.5
› npm --version
2.11.2

PS. I'm using time-grunt, chalk in other projects and never seen anything like that.

Gruntfile.js

Add ability to use different color for charts

Working in a terminal window with a black background, the blue bars and time results are flat-out illegible and borderline-impossible to read. If there were any way to specify some sort of custom color setting, or if it were possible to use a color with better contrast on both black and white backgrounds, that would be really nice.

capture

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.